diff --git a/src/ngSanitize/sanitize.js b/src/ngSanitize/sanitize.js index 9240309c5b48..ae11a825d5d3 100644 --- a/src/ngSanitize/sanitize.js +++ b/src/ngSanitize/sanitize.js @@ -350,7 +350,7 @@ function htmlParser(html, handler) { } else { // IE versions 9 and 10 do not understand the regex '[^]', so using a workaround with [\W\w]. - html = html.replace(new RegExp("([\\W\\w]*)<\\s*\\/\\s*" + stack.last() + "[^>]*>", 'i'), + html = html.replace(new RegExp("([\\W\\w]*?)<\\s*\\/\\s*" + stack.last() + "[^>]*>", 'i'), function(all, text) { text = text.replace(COMMENT_REGEXP, "$1").replace(CDATA_REGEXP, "$1"); diff --git a/test/ngSanitize/sanitizeSpec.js b/test/ngSanitize/sanitizeSpec.js index 33d036c97efc..fe7f83cf98a7 100644 --- a/test/ngSanitize/sanitizeSpec.js +++ b/test/ngSanitize/sanitizeSpec.js @@ -176,6 +176,10 @@ describe('HTML', function() { expectHTML('ailc.').toEqual('ac.'); }); + it('should not remove elements between script elements', function() { + expectHTML('abc.').toEqual('abc.'); + }); + it('should remove unknown names', function() { expectHTML('abc').toEqual('abc'); });