Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Encode opening brackets in contextDump helper #94

Merged
merged 1 commit into from
Oct 10, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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