Skip to content

Commit

Permalink
Fix unescaping in matlab, miniMAL and rpython.
Browse files Browse the repository at this point in the history
  • Loading branch information
kanaka committed Sep 28, 2017
1 parent ea02f46 commit 273226a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
3 changes: 2 additions & 1 deletion matlab/reader.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@
atm = str2double(token);
elseif strcmp(token(1), '"')
atm = token(2:length(token)-1);
atm = strrep(atm, '\\', char(255));
atm = strrep(atm, '\"', '"');
atm = strrep(atm, '\n', char(10));
atm = strrep(atm, '\\', '\');
atm = strrep(atm, char(255), '\');
elseif strcmp(token(1), ':')
s = token(2:end);
atm = type_utils.keyword(s);
Expand Down
12 changes: 6 additions & 6 deletions miniMAL/reader.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@
["parseInt", "token", 10],
["if", ["=", ["`", "\""], ["get", "token", 0]],
[".",
[".",
[".",
["slice", "token", 1, ["-", ["count", "token"], 1]],
["`", "replace"], ["RegExp", ["`", "\\\\\""], ["`", "g"]], ["`", "\""]],
["`", "replace"], ["RegExp", ["`", "\\\\n"], ["`", "g"]], ["`", "\n"]],
["`", "replace"], ["RegExp", ["`", "\\\\\\\\"], ["`", "g"]], ["`", "\\"]],
["slice", "token", 1, ["-", ["count", "token"], 1]],
["`", "replace"], ["RegExp", ["`", "\\\\(.)"], ["`", "g"]],
["fn", ["_", "c"],
["if", ["=", "c", ["`", "n"]],
["`", "\n"],
"c"]]],
["if", ["=", ["`", ":"], ["get", "token", 0]],
["keyword", ["slice", "token", 1]],
["if", ["=", ["`", "nil"], "token"],
Expand Down
3 changes: 2 additions & 1 deletion rpython/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,10 @@ def read_atom(reader):
return MalStr(u"")
else:
s = unicode(token[1:end])
s = types._replace(u'\\\\', u"\u029e", s)
s = types._replace(u'\\"', u'"', s)
s = types._replace(u'\\n', u"\n", s)
s = types._replace(u'\\\\', u"\\", s)
s = types._replace(u"\u029e", u"\\", s)
return MalStr(s)
elif token[0] == ':': return _keywordu(unicode(token[1:]))
elif token == "nil": return types.nil
Expand Down

0 comments on commit 273226a

Please sign in to comment.