Fixed regression with extension omnibox API where whitespace would get trimmed

after style markup, introduced by r107746.

BUG=106355
TEST=see bug for repro


Review URL: http://codereview.chromium.org/8824018

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@113554 0039d316-1c4b-4281-b951-d872f2087c98
parent ee595583
...@@ -472,11 +472,13 @@ var chrome = chrome || {}; ...@@ -472,11 +472,13 @@ var chrome = chrome || {};
// Remove invalid characters from |text| so that it is suitable to use // Remove invalid characters from |text| so that it is suitable to use
// for |AutocompleteMatch::contents|. // for |AutocompleteMatch::contents|.
function sanitizeString(text) { function sanitizeString(text, shouldTrim) {
// NOTE: This logic mirrors |AutocompleteMatch::SanitizeString()|. // NOTE: This logic mirrors |AutocompleteMatch::SanitizeString()|.
// 0x2028 = line separator; 0x2029 = paragraph separator. // 0x2028 = line separator; 0x2029 = paragraph separator.
var kRemoveChars = /(\r|\n|\t|\u2028|\u2029)/gm; var kRemoveChars = /(\r|\n|\t|\u2028|\u2029)/gm;
return text.trimLeft().replace(kRemoveChars, ''); if (shouldTrim)
text = text.trimLeft();
return text.replace(kRemoveChars, '');
} }
// Parses the xml syntax supported by omnibox suggestion results. Returns an // Parses the xml syntax supported by omnibox suggestion results. Returns an
...@@ -510,7 +512,8 @@ var chrome = chrome || {}; ...@@ -510,7 +512,8 @@ var chrome = chrome || {};
for (var i = 0, child; child = node.childNodes[i]; i++) { for (var i = 0, child; child = node.childNodes[i]; i++) {
// Append text nodes to our description. // Append text nodes to our description.
if (child.nodeType == Node.TEXT_NODE) { if (child.nodeType == Node.TEXT_NODE) {
result.description += sanitizeString(child.nodeValue); var shouldTrim = result.description.length == 0;
result.description += sanitizeString(child.nodeValue, shouldTrim);
continue; continue;
} }
......
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