[asterisk-users] Multiple readfile oddities, newlines etc

Jonathan H lardconcepts at gmail.com
Tue Oct 29 04:47:56 CDT 2019


October 2019, Asterisk 17.0, this is still happening

Bug updated:  https://issues.asterisk.org/jira/browse/ASTERISK-26481

File is a single line unix-line UTF-8 file, with  "1," (no quote marks)

hexdump output is as follows

0000000 2c31
0000002

dialplan is


    same =>
n(skipto),Set(unfilteredfeat=${FILE(${scanPath}/skipto.txt,0,1,l,u)})
    same => n,Set(feature=${SHIFT(unfilteredfeat)})
    same => n,Verbose(1,feature is ${feature} unfilteredfeat is
${unfilteredfeat})


Console log output is


    -- Executing [s at root:40] Set("Local/s at root-00000011;2",
"unfilteredfeat=1,▒=") in new stack
[Oct 29 09:36:15] ERROR[2134][C-00000012]: json.c:607 ast_json_vpack: Error
building JSON from '{s: s, s: s}': Invalid UTF-8 string.
[Oct 29 09:36:15] ERROR[2134][C-00000012]:   Got 11 backtrace records
# 0: /usr/sbin/asterisk(ast_json_pack+0xa5) [0x5627588a7f45]
# 1: /usr/sbin/asterisk(ast_channel_publish_varset+0x30) [0x562758937820]
# 2: /usr/sbin/asterisk(pbx_builtin_setvar_helper+0x148) [0x5627588e8e78]
# 3: /usr/sbin/asterisk(pbx_builtin_setvar+0x119) [0x5627588e9209]
# 4: /usr/sbin/asterisk(pbx_exec+0x158) [0x5627588dedf8]
# 5: /usr/sbin/asterisk(+0x137479) [0x5627588d3479]
# 6: /usr/sbin/asterisk(+0x139134) [0x5627588d5134]
# 7: /usr/sbin/asterisk(+0x13a7a1) [0x5627588d67a1]
# 8: /usr/sbin/asterisk(+0x1bd598) [0x562758959598]
# 9: /lib/x86_64-linux-gnu/libpthread.so.0(+0x9669) [0x7fa95fd1b669]
#10: /lib/x86_64-linux-gnu/libc.so.6(clone+0x43) [0x7fa95fa9f323]

[Oct 29 09:36:15] ERROR[2134][C-00000012]: stasis_channels.c:1161
ast_channel_publish_varset: Error creating message
[Oct 29 09:36:15] ERROR[2134][C-00000012]: json.c:607 ast_json_vpack: Error
building JSON from '{s: s, s: s}': Invalid UTF-8 string.
[Oct 29 09:36:15] ERROR[2134][C-00000012]:   Got 12 backtrace records
# 0: /usr/sbin/asterisk(ast_json_pack+0xa5) [0x5627588a7f45]
# 1: /usr/sbin/asterisk(ast_channel_publish_varset+0x30) [0x562758937820]
# 2: /usr/sbin/asterisk(pbx_builtin_setvar_helper+0x148) [0x5627588e8e78]
# 3: /usr/lib/asterisk/modules/func_strings.so(+0x64c0) [0x7fa93fd054c0]
# 4: /usr/sbin/asterisk(ast_func_read+0x326) [0x5627588e35b6]
# 5: /usr/sbin/asterisk(pbx_substitute_variables_helper_full+0x282)
[0x5627588e7cc2]
# 6: /usr/sbin/asterisk(+0x137445) [0x5627588d3445]
# 7: /usr/sbin/asterisk(+0x139134) [0x5627588d5134]
# 8: /usr/sbin/asterisk(+0x13a7a1) [0x5627588d67a1]
# 9: /usr/sbin/asterisk(+0x1bd598) [0x562758959598]
#10: /lib/x86_64-linux-gnu/libpthread.so.0(+0x9669) [0x7fa95fd1b669]
#11: /lib/x86_64-linux-gnu/libc.so.6(clone+0x43) [0x7fa95fa9f323]

[Oct 29 09:36:15] ERROR[2134][C-00000012]: stasis_channels.c:1161
ast_channel_publish_varset: Error creating message
    -- Executing [s at root:42] Set("Local/s at root-00000011;2", "feature=1") in
new stack
    -- Executing [s at root:43] Verbose("Local/s at root-00000011;2", "1,feature
is 1 unfilteredfeat is ▒=") in new stack
 feature is 1 unfilteredfeat is ▒=


On Tue, 18 Oct 2016 at 12:41, Jonathan H <lardconcepts at gmail.com> wrote:

> I'm going to go ahead and file a bug report, 'cos something definitely
> ain't right here! Bug filed:
> https://issues.asterisk.org/jira/browse/ASTERISK-26481
>
> This bit of dialplan.....
>
> exten => 5,1,Verbose(Context: ${CONTEXT} Exten:${EXTEN})
>     same => n,Set(featurefile=/home/test/feature-1.txt)
>     same =>
> n,set(myList=1,12,123,1234,12345,123456,A,AB,ABC,ABCD,ABCDE,ABC123)
>     same => n,While($["${SET(rawVar=${SHIFT(myList)})}" != ""])
>     same => n,SET(FILE(${featurefile})=${rawVar})
>     same => n,SET(fileVar=${FILE(${featurefile},0,1,l,u)})
>     same => n,SET(hexDump=${SHELL(hd ${featurefile})})
>     same => n,Verbose(Before file: ---${rawVar}--- len ${LEN(rawVar)}
> after file: ---${fileVar}--- len ${LEN(fileVar)} hexdump:${hexDump})
>     same => n,EndWhile()
>     same => n,Hangup()
>
>
> ...produces this output: (tidied only for posting) - this is messed up
> in so many ways.
>
> LEN is showing the wrong length.
> 1 character gets a weird character added.
> 23, and 4  characters OK
> 5 characters loses a character - BUT LOOK! Even though hexdump prints
> the correct contents and length, have a close look at this: 35|12345|
> whereas normally it would have a space before the pipe.
> 6 characters is OK
>
> Before file: ---1--- len 6 after file: ---1▒--- len 7 hexdump:00000000
>  31|1| 00000001
> Before file: ---12--- len 6 after file: ---12--- len 7
> hexdump:00000000  31 32 |12| 00000002
> Before file: ---123--- len 6 after file: ---123--- len 7
> hexdump:00000000  31 32 33  |123| 00000003
>
> [Oct 18 12:23:53] ERROR[8584][C-0000001a]: json.c:704 ast_json_vpack:
> Error building JSON from '{s: s, s: s}': Invalid UTF-8 string.
> [Oct 18 12:23:53] ERROR[8584][C-0000001a]: stasis_channels.c:773
> ast_channel_publish_varset: Error creating message
>
> Before file: ---1234--- len 6 after file: ---1234--- len 7
> hexdump:00000000  31 32 33 34   |1234| 00000004
> Before file: ---12345--- len 6 after file: ---1234--- len 7
> hexdump:00000000  31 32 33 34 35|12345| 00000005
> Before file: ---123456--- len 6 after file: ---123456--- len 7
> hexdump:00000000  31 32 33 34 35 36 |123456| 00000006
>
> [Oct 18 12:23:53] ERROR[8584][C-0000001a]: json.c:704 ast_json_vpack:
> Error building JSON from '{s: s, s: s}': Invalid UTF-8 string.
> [Oct 18 12:23:53] ERROR[8584][C-0000001a]: stasis_channels.c:773
> ast_channel_publish_varset: Error creating message
>
> Before file: ---A--- len 6 after file: ---A▒--- len 7 hexdump:00000000
>  41|A| 00000001
> Before file: ---AB--- len 6 after file: ---AB--- len 7
> hexdump:00000000  41 42 |AB| 00000002
> Before file: ---ABC--- len 6 after file: ---ABC--- len 7
> hexdump:00000000  41 42 43  |ABC| 00000003
>
> [Oct 18 12:23:53] ERROR[8584][C-0000001a]: json.c:704 ast_json_vpack:
> Error building JSON from '{s: s, s: s}': Invalid UTF-8 string.
> [Oct 18 12:23:53] ERROR[8584][C-0000001a]: stasis_channels.c:773
> ast_channel_publish_varset: Error creating message
>
> Before file: ---ABCD--- len 6 after file: ---ABCD--- len 7
> hexdump:00000000  41 42 43 44   |ABCD| 00000004
> Before file: ---ABCDE--- len 6 after file: ---ABCD--- len 7
> hexdump:00000000  41 42 43 44 45|ABCDE| 00000005
> Before file: ---ABC123--- len 6 after file: ---ABC123--- len 7
> hexdump:00000000  41 42 43 31 32 33 |ABC123|
>
> On 17 October 2016 at 23:12, Pete Mundy <pete at fiberphone.co.nz> wrote:
> > On 18/10/2016, at 10:38 am, Steve Edwards <asterisk.org at sedwards.com>
> wrote:
> >
> > cat /home/test/feature-1.txt | hexdump
> >
> >
> > Or just:
> >
> > hexdump /home/test/feature-1.txt
> >
> >
> > Heh.. yes, fair call ;)
> >
> > Pete
> >
> >
> > --
> > _____________________________________________________________________
> > -- Bandwidth and Colocation Provided by http://www.api-digital.com --
> >
> > Join the Asterisk Community at the 13th AstriCon, September 27-29, 2016
> >       http://www.asterisk.org/community/astricon-user-conference
> >
> > New to Asterisk? Start here:
> >       https://wiki.asterisk.org/wiki/display/AST/Getting+Started
> >
> > asterisk-users mailing list
> > To UNSUBSCRIBE or update options visit:
> >    http://lists.digium.com/mailman/listinfo/asterisk-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-users/attachments/20191029/3663c604/attachment.html>


More information about the asterisk-users mailing list