File tree 2 files changed +7
-4
lines changed
2 files changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -164,10 +164,6 @@ defimpl Poison.Encoder, for: BitString do
164
164
[ "\\ /" | escape ( rest , :html_safe ) ]
165
165
end
166
166
167
- defp escape ( << char :: utf8 >> <> rest , :html_safe ) do
168
- [ char | escape ( rest , :html_safe ) ]
169
- end
170
-
171
167
defp escape ( string , mode ) do
172
168
size = chunk_size ( string , mode , 0 )
173
169
<< chunk :: binary - size ( size ) , rest :: binary >> = string
@@ -179,6 +175,10 @@ defimpl Poison.Encoder, for: BitString do
179
175
acc
180
176
end
181
177
178
+ defp chunk_size ( << ?/ :: utf8 >> <> _ , :html_safe , acc ) do
179
+ acc
180
+ end
181
+
182
182
defp chunk_size ( << char >> <> rest , mode , acc ) when char < 0x80 do
183
183
chunk_size ( rest , mode , acc + 1 )
184
184
end
Original file line number Diff line number Diff line change @@ -32,6 +32,9 @@ defmodule Poison.EncoderTest do
32
32
assert to_json ( "\u2028 \u2029 " , escape: :javascript ) == ~s( "\\ u2028\\ u2029")
33
33
assert to_json ( "</script>" , escape: :html_safe ) == ~s( "<\\ /script>")
34
34
35
+ assert to_json ( "\uCCCC </script>\uCCCC " , escape: :html_safe ) ==
36
+ ~s( "쳌<\\ /script>쳌")
37
+
35
38
assert to_json ( ~s( <script>var s = "\u2028 \u2029 ";</script>) ,
36
39
escape: :html_safe
37
40
) == ~s( "<script>var s = \\ \" \\ u2028\\ u2029\\ \" ;<\\ /script>")
You can’t perform that action at this time.
0 commit comments