Skip to content

Commit

Permalink
Merge pull request #94 from prashn64/contextDump-jsEncode
Browse files Browse the repository at this point in the history
Encode opening brackets in contextDump helper
  • Loading branch information
jimmyhchan committed Oct 10, 2014
2 parents c0daff0 + 03cd65f commit 613e2b7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/dust-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,9 @@ var helpers = {
return chunk;
}
else {
// encode opening brackets when outputting to html
dump = dump.replace(/</g, '\\u003c');

return chunk.write(dump);
}
},
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 613e2b7

Please sign in to comment.