Permalink
Browse files

fix misencoding of backslash characters; add regression test case for…

… this
  • Loading branch information...
1 parent f2b691d commit 07c37bf644a472e04932d9b580d5426c1b3a0c55 @mdempsky mdempsky committed Feb 17, 2008
Showing with 3 additions and 2 deletions.
  1. +3 −2 src/mochijson.erl
View
5 src/mochijson.erl
@@ -174,8 +174,8 @@ json_encode_string_utf8(S) ->
json_encode_string_utf8_1([C | Cs]) when C >= 0, C =< 16#7f ->
NewC = case C of
- _ when C >= $\s, C < 16#7f -> C;
$\\ -> "\\\\";
+ _ when C >= $\s, C < 16#7f -> C;
$\t -> "\\t";
$\n -> "\\n";
$\r -> "\\r";
@@ -195,8 +195,8 @@ json_encode_string_unicode(S) ->
json_encode_string_unicode_1([C | Cs]) ->
NewC = case C of
- _ when C >= $\s, C < 16#7f -> C;
$\\ -> "\\\\";
+ _ when C >= $\s, C < 16#7f -> C;
$\t -> "\\t";
$\n -> "\\n";
$\r -> "\\r";
@@ -498,6 +498,7 @@ e2j_test_vec(utf8) ->
{"", "\"\""},
{[], "\"\""},
{"\n\n\n", "\"\\n\\n\\n\""},
+ {"\\", "\"\\\\\""},
{obj_new(), "{}"},
{obj_from_list([{"foo", "bar"}]), "{\"foo\":\"bar\"}"},
{obj_from_list([{"foo", "bar"}, {"baz", 123}]),

0 comments on commit 07c37bf

Please sign in to comment.