Skip to content

Commit c3fcd1d

Browse files
committed
fixed an issue where escaping didn't work properly for \uXXXX unicode sequences.
1 parent 5a77f18 commit c3fcd1d

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

src/json_string_utilities.F90

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,23 @@ subroutine escape_string(str_in, str_out)
335335
if (ipos+3>len(str_out)) str_out = str_out // repeat(space, chunk_size)
336336

337337
select case(c)
338-
case(quotation_mark,backslash,slash)
338+
case(backslash)
339+
340+
!test for unicode sequence: '\uXXXX'
341+
![don't add an extra '\' for those]
342+
if (i+5<=len(str_in)) then
343+
if (str_in(i+1:i+1)==CK_'u' .and. &
344+
valid_json_hex(str_in(i+2:i+5))) then
345+
str_out(ipos:ipos) = c
346+
ipos = ipos + 1
347+
cycle
348+
end if
349+
end if
350+
351+
str_out(ipos:ipos+1) = backslash//c
352+
ipos = ipos + 2
353+
354+
case(quotation_mark,slash)
339355
str_out(ipos:ipos+1) = backslash//c
340356
ipos = ipos + 2
341357
case(bspace)

0 commit comments

Comments
 (0)