Skip to content

Commit bbd14ce

Browse files
committed
fix(minErr): encode btstrpd error input to strip angle brackets
The $sanitize service was returning an empty string to the error page because the input was usually a single html tag (sometimes it could be `document`). This fix replaces angle brackets with html entities. Closes angular#8683
1 parent 14b3db3 commit bbd14ce

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/Angular.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -1395,7 +1395,11 @@ function bootstrap(element, modules, config) {
13951395

13961396
if (element.injector()) {
13971397
var tag = (element[0] === document) ? 'document' : startingTag(element);
1398-
throw ngMinErr('btstrpd', "App Already Bootstrapped with this Element '{0}'", tag);
1398+
//Encode angle brackets to prevent input from being sanitized to empty string #8683
1399+
throw ngMinErr(
1400+
'btstrpd',
1401+
"App Already Bootstrapped with this Element '{0}'",
1402+
tag.replace(/</,'&lt;').replace(/>/,'&gt;'));
13991403
}
14001404

14011405
modules = modules || [];

test/AngularSpec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -786,7 +786,7 @@ describe('angular', function() {
786786
expect(function () {
787787
angular.bootstrap(element);
788788
}).toThrowMatching(
789-
/\[ng:btstrpd\] App Already Bootstrapped with this Element '<div class="?ng\-scope"?( ng[0-9]+="?[0-9]+"?)?>'/i
789+
/\[ng:btstrpd\] App Already Bootstrapped with this Element '&lt;div class="?ng\-scope"?( ng[0-9]+="?[0-9]+"?)?&gt;'/i
790790
);
791791

792792
dealoc(element);

0 commit comments

Comments
 (0)