Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(416)

Unified Diff: chrome/renderer/resources/extensions/extension_process_bindings.js

Issue 8364001: Strip special characters in extension omnibox suggestions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/autocomplete/extension_app_provider_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/resources/extensions/extension_process_bindings.js
===================================================================
--- chrome/renderer/resources/extensions/extension_process_bindings.js (revision 107565)
+++ chrome/renderer/resources/extensions/extension_process_bindings.js (working copy)
@@ -445,6 +445,15 @@
};
}
+ // Remove invalid characters from |text| so that it is suitable to use
+ // for |AutocompleteMatch::contents|.
+ function sanitizeString(text) {
+ // NOTE: This logic mirrors |AutocompleteMatch::SanitizeString()|.
+ // 0x2028 = line separator; 0x2029 = paragraph separator.
+ var kRemoveChars = /(\r|\n|\t|\u2028|\u2029)/gm;
+ return text.trimLeft().replace(kRemoveChars, '');
+ }
+
// Parses the xml syntax supported by omnibox suggestion results. Returns an
// object with two properties: 'description', which is just the text content,
// and 'descriptionStyles', which is an array of style objects in a format
@@ -476,7 +485,7 @@
for (var i = 0, child; child = node.childNodes[i]; i++) {
// Append text nodes to our description.
if (child.nodeType == Node.TEXT_NODE) {
- result.description += child.nodeValue;
+ result.description += sanitizeString(child.nodeValue);
continue;
}
« no previous file with comments | « chrome/browser/autocomplete/extension_app_provider_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698