Commit 195ae3b6 authored by Hector Carmona's avatar Hector Carmona Committed by Commit Bot

MD Extensions: Fix overly aggressive sanitation.

Polymer already protects against XSS injection, we just need to
combine the two strings.

Bug: 822939
Cq-Include-Trybots: master.tryserver.chromium.linux:closure_compilation
Change-Id: I866d65419b22d63a1c5a460f6a30304e4a5d487a
Reviewed-on: https://chromium-review.googlesource.com/981599
Commit-Queue: Hector Carmona <hcarmona@chromium.org>
Reviewed-by: default avatarDemetrios Papadopoulos <dpapad@chromium.org>
Reviewed-by: default avatarDevlin <rdevlin.cronin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#547113}
parent 9f7ed66f
...@@ -109,7 +109,12 @@ cr.define('extensions', function() { ...@@ -109,7 +109,12 @@ cr.define('extensions', function() {
/** @private string */ /** @private string */
a11yAssociation_: function() { a11yAssociation_: function() {
return this.i18n('extensionA11yAssociation', this.data.name); // Don't use I18nBehavior.i18n because of additional checks it performs.
// Polymer ensures that this string is not stamped into arbitrary HTML.
// |this.data.name| can contain any data including html tags.
// ex: "My <video> download extension!"
return loadTimeData.getStringF(
'extensionA11yAssociation', this.data.name);
}, },
/** @private */ /** @private */
......
...@@ -192,6 +192,10 @@ TEST_F('CrExtensionsItemsTest', 'RemoveButton', function() { ...@@ -192,6 +192,10 @@ TEST_F('CrExtensionsItemsTest', 'RemoveButton', function() {
this.runMochaTest(extension_item_tests.TestNames.RemoveButton); this.runMochaTest(extension_item_tests.TestNames.RemoveButton);
}); });
TEST_F('CrExtensionsItemsTest', 'HtmlInName', function() {
this.runMochaTest(extension_item_tests.TestNames.HtmlInName);
});
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Extension Detail View Tests // Extension Detail View Tests
......
...@@ -74,6 +74,7 @@ cr.define('extension_item_tests', function() { ...@@ -74,6 +74,7 @@ cr.define('extension_item_tests', function() {
SourceIndicator: 'source indicator', SourceIndicator: 'source indicator',
EnableToggle: 'toggle is disabled when necessary', EnableToggle: 'toggle is disabled when necessary',
RemoveButton: 'remove button hidden when necessary', RemoveButton: 'remove button hidden when necessary',
HtmlInName: 'html in extension name',
}; };
var suiteName = 'ExtensionItemTest'; var suiteName = 'ExtensionItemTest';
...@@ -322,6 +323,16 @@ cr.define('extension_item_tests', function() { ...@@ -322,6 +323,16 @@ cr.define('extension_item_tests', function() {
Polymer.dom.flush(); Polymer.dom.flush();
expectTrue(item.$['remove-button'].hidden); expectTrue(item.$['remove-button'].hidden);
}); });
test(assert(TestNames.HtmlInName), function() {
let name = '<HTML> in the name!';
item.set('data.name', name);
Polymer.dom.flush();
assertEquals(name, item.$.name.textContent.trim());
// "Related to $1" is IDS_MD_EXTENSIONS_EXTENSION_A11Y_ASSOCIATION.
assertEquals(
`Related to ${name}`, item.$.a11yAssociation.textContent.trim());
});
}); });
return { return {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment