From bcde9a3695065c05c9cd44fba026187e2cf24001 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Thu, 26 Nov 2015 10:44:28 +0100 Subject: [PATCH] Also remove svg in htmlCleanup(), htmlRemoveTags() and htmlRemoveRichtext(). --- .../javascripts/app/lib/app_post/utils.coffee | 8 ++++---- public/assets/tests/html-utils.js | 16 ++++++++-------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/app/assets/javascripts/app/lib/app_post/utils.coffee b/app/assets/javascripts/app/lib/app_post/utils.coffee index 787cf2397..01520a2ad 100644 --- a/app/assets/javascripts/app/lib/app_post/utils.coffee +++ b/app/assets/javascripts/app/lib/app_post/utils.coffee @@ -116,7 +116,7 @@ class App.Utils ) # remove tags & content - html.find('div, span, p, li, ul, ol, a, b, u, i, label, small, strong, strike, pre, code, center, blockquote, form, textarea, font, table, thead, tbody, tr, td, h1, h2, h3, h4, h5, h6, br, hr, img, input, select, button, style, applet, embed, noframes, canvas, script, frame, iframe').remove() + html.find('div, span, p, li, ul, ol, a, b, u, i, label, small, strong, strike, pre, code, center, blockquote, form, textarea, font, table, thead, tbody, tr, td, h1, h2, h3, h4, h5, h6, br, hr, img, svg, input, select, button, style, applet, embed, noframes, canvas, script, frame, iframe').remove() html @@ -138,7 +138,7 @@ class App.Utils ) # remove tags & content - html.find('li, ul, ol, a, b, u, i, label, small, strong, strike, pre, code, center, blockquote, form, textarea, font, address, table, thead, tbody, tr, td, h1, h2, h3, h4, h5, h6, hr, img, input, select, button, style, applet, embed, noframes, canvas, script, frame, iframe').remove() + html.find('li, ul, ol, a, b, u, i, label, small, strong, strike, pre, code, center, blockquote, form, textarea, font, address, table, thead, tbody, tr, td, h1, h2, h3, h4, h5, h6, hr, img, svg, input, select, button, style, applet, embed, noframes, canvas, script, frame, iframe').remove() html @@ -155,7 +155,7 @@ class App.Utils @_removeWordMarkup(html) # remove tags, keep content - html.find('a, font, small, time').replaceWith( -> + html.find('a, font, small, time, form').replaceWith( -> $(@).contents() ) @@ -179,7 +179,7 @@ class App.Utils ) # remove tags & content - html.find('form, font, hr, img, input, select, button, style, applet, embed, noframes, canvas, script, frame, iframe').remove() + html.find('font, hr, img, svg, input, select, button, style, applet, embed, noframes, canvas, script, frame, iframe').remove() html diff --git a/public/assets/tests/html-utils.js b/public/assets/tests/html-utils.js index 2d190d843..385ddcde7 100644 --- a/public/assets/tests/html-utils.js +++ b/public/assets/tests/html-utils.js @@ -246,7 +246,7 @@ test("htmlRemoveTags", function() { result = App.Utils.htmlRemoveTags($(source)) equal(result.html(), should, source) - source = "
test 123
" + source = "
test 123
" //should = "
test 123
" should = "test 123" result = App.Utils.htmlRemoveRichtext($(source)) @@ -345,7 +345,7 @@ test("htmlRemoveRichtext", function() { result = App.Utils.htmlRemoveRichtext($(source)) equal(result.html(), should, source) - source = "
This is some text!
" + source = "
This is some text!
" //should = "
This is some text!
" should = "This is some text!" result = App.Utils.htmlRemoveRichtext($(source)) @@ -400,31 +400,31 @@ test("htmlCleanup", function() { source = "

" //should = "

" should = "

" - result = App.Utils.htmlRemoveRichtext($(source)) + result = App.Utils.htmlCleanup($(source)) equal(result.html(), should, source) source = "
test 123
" //should = "
test 123
" should = "test 123" - result = App.Utils.htmlRemoveRichtext($(source)) + result = App.Utils.htmlCleanup($(source)) equal(result.html(), should, source) source = "
test 123
some other value
" //should = "
test 123 some other value
" should = "test 123 some other value" - result = App.Utils.htmlRemoveRichtext($(source)) + result = App.Utils.htmlCleanup($(source)) equal(result.html(), should, source) source = "
test 123
some other value
" //should = "
test 123 some other value
" should = "test 123 some other value" - result = App.Utils.htmlRemoveRichtext($(source)) + result = App.Utils.htmlCleanup($(source)) equal(result.html(), should, source) - source = "
This is some text!
" + source = "
This is some text!
" //should = "
This is some text!
" should = "This is some text!" - result = App.Utils.htmlRemoveRichtext($(source)) + result = App.Utils.htmlCleanup($(source)) equal(result.html(), should, source) source = "

some link to somewhere from wordabc

"