From 364c52bc1b73638d6d66b2da4958cd07118c118f Mon Sep 17 00:00:00 2001 From: Rob Wu Date: Wed, 9 Nov 2016 00:45:34 +0100 Subject: [PATCH] Fix order of decoding entities (#1049) --- components/prism-groovy.js | 2 +- tests/languages/groovy/issue1049.js | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 tests/languages/groovy/issue1049.js diff --git a/components/prism-groovy.js b/components/prism-groovy.js index 7ecef42994..c6f749e330 100644 --- a/components/prism-groovy.js +++ b/components/prism-groovy.js @@ -49,7 +49,7 @@ Prism.hooks.add('wrap', function(env) { } // To prevent double HTML-encoding we have to decode env.content first - env.content = env.content.replace(/&/g, '&').replace(/</g, '<'); + env.content = env.content.replace(/</g, '<').replace(/&/g, '&'); env.content = Prism.highlight(env.content, { 'expression': { diff --git a/tests/languages/groovy/issue1049.js b/tests/languages/groovy/issue1049.js new file mode 100644 index 0000000000..2ce81537a2 --- /dev/null +++ b/tests/languages/groovy/issue1049.js @@ -0,0 +1,8 @@ +module.exports = { + '"&"': '"&amp;"', + '"&&"': '"&amp;&amp;"', + '"<"': '"&lt;"', + '"<<"': '"&lt;&lt;"', + '"&lt;"': '"&amp;lt;"', + '">"': '"&gt;"', +};