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
000 2c31
002
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@root:40] Set("Local/s@root-0011;2",
"unfilteredfeat=1,▒=") in new stack
[Oct 29 09:36:15] ERROR[2134][C-0012]: 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-0012]: 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-0012]: stasis_channels.c:1161
ast_channel_publish_varset: Error creating message
[Oct 29 09:36:15] ERROR[2134][C-0012]: 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-0012]: 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-0012]: stasis_channels.c:1161
ast_channel_publish_varset: Error creating message
-- Executing [s@root:42] Set("Local/s@root-0011;2", "feature=1") in
new stack
-- Executing [s@root:43] Verbose("Local/s@root-0011;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 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:
> 31|1| 0001
> Before file: ---12--- len 6 after file: ---12--- len 7
> hexdump: 31 32 |12| 0002
> Before file: ---123--- len 6 after file: ---123--- len 7
> hexdump: 31 32 33 |123| 0003
>
> [Oct 18 12:23:53] ERROR[8584][C-001a]: 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-001a]: stasis_channels.c:773
> ast_channel_publish_varset: Error creating message
>
> Before file: ---1234--- len 6 after file: ---1234--- len 7
> hexdump: 31 32 33 34 |1234| 0004
> Before file: ---12345--- len 6 after file: ---1234--- len 7
> hexdump: 31 32 33 34 35|123