Skip to content

Commit

Permalink
Encode opening brackets in contextDump helper
Browse files Browse the repository at this point in the history
  • Loading branch information
Prayrit Jain committed Oct 6, 2014
1 parent c0daff0 commit b4940ae
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/dust-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,8 @@ var helpers = {
else {
dump = JSON.stringify(context.stack.head, jsonFilter, 2);
}
// encode opening brackets
dump = dump.replace(/</g, '\\u003c');
if (to === 'console') {
_log(dump);
return chunk;
Expand Down
7 changes: 7 additions & 0 deletions test/jasmine-test/spec/helpersTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -1253,6 +1253,13 @@
context: { "aa": ["a"], "p" : 42},
expected: "{\n \"tail\": {\n \"tail\": {\n \"isObject\": true,\n \"head\": {\n \"aa\": [\n \"a\"\n ],\n \"p\": 42\n }\n },\n \"isObject\": true,\n \"head\": {\n \"param\": \"function body_2(chk, ctx) {return chk.reference(ctx.get([\\\"p\\\"], false), ctx, \\\"h\\\");}\",\n \"$len\": 1,\n \"$idx\": 0\n }\n },\n \"isObject\": false,\n \"head\": \"a\",\n \"index\": 0,\n \"of\": 1\n}",
message: "contextDump function dump test"
},
{
name: "contextDump encoding test",
source: "{@contextDump/}",
context: { "A": "<html>", "B": "</html>"},
expected: "{\n \"A\": \"\\u003chtml>\",\n \"B\": \"\\u003c/html>\"\n}",
message: "contextDump simple test"
}
]
},
Expand Down

0 comments on commit b4940ae

Please sign in to comment.