A platform for community discussion. Free, open, simple.
FEATURE: whitelist lang attribute
Sam0b3d51a8bc43
diff --git a/app/assets/javascripts/pretty-text/white-lister.js.es6 b/app/assets/javascripts/pretty-text/white-lister.js.es6index a2c22f99885..caa0afc828b 100644--- a/app/assets/javascripts/pretty-text/white-lister.js.es6+++ b/app/assets/javascripts/pretty-text/white-lister.js.es6@@ -136,6 +136,7 @@ const DEFAULT_LIST = ["div.quote-controls","div.title","div[align]",+ "div[lang]","div[data-*]" /* This may seem a bit much but polls doesit anyway and this is needed for themes,special code in sanitizer handles data-*@@ -170,9 +171,11 @@ const DEFAULT_LIST = ["ol","ol[start]","p",+ "p[lang]","pre","s","small",+ "span[lang]","span.excerpt","span.hashtag","span.mention",diff --git a/spec/components/pretty_text_spec.rb b/spec/components/pretty_text_spec.rbindex 10fddf0e503..546eacfe803 100644--- a/spec/components/pretty_text_spec.rb+++ b/spec/components/pretty_text_spec.rb@@ -1307,4 +1307,9 @@ HTMLexpect(cooked).to include("data-theme-a")end+ it "whitelists lang attribute" do+ cooked = PrettyText.cook("<p lang='fr'>tester</p><div lang='fr'>tester</div><span lang='fr'>tester</span>")+ expect(cooked).to eq("<p lang=\"fr\">tester</p><div lang=\"fr\">tester</div><span lang=\"fr\">tester</span>")+ end+end