From 8454a8c59b4703df3253ec611ad17c4677517c76 Mon Sep 17 00:00:00 2001 From: Caitlin Potter Date: Thu, 28 Nov 2013 18:39:46 -0500 Subject: [PATCH] fix(ngSanitize): prevent decodeEntities from prepending original text to output Clearing the match before the conditional branch seems to (inexplicably) break Safari 7 on OSX 10.9, except when stepping through line by line. Moving the assignment to after the conditional branch corrects this behaviour. --- src/ngSanitize/sanitize.js | 2 +- test/ngSanitize/sanitizeSpec.js | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/ngSanitize/sanitize.js b/src/ngSanitize/sanitize.js index 5d378b02cac3..ea9de7b7f1a5 100644 --- a/src/ngSanitize/sanitize.js +++ b/src/ngSanitize/sanitize.js @@ -373,11 +373,11 @@ function decodeEntities(value) { // Note: IE8 does not preserve spaces at the start/end of innerHTML var spaceRe = /^(\s*)([\s\S]*?)(\s*)$/; var parts = spaceRe.exec(value); - parts[0] = ''; if (parts[2]) { hiddenPre.innerHTML=parts[2].replace(/&c')).toEqual('a<div>&</div>c'); }); }); + + describe('decodeEntities', function() { + it('should not prepend the original string to the output', function() { + expect(decodeEntities('John Due ☺')).toEqual('John Due ☺'); + }); + }); });