зеркало из https://github.com/mozilla/pjs.git
Bug 454090 - Use .trim() in search service, r=gavin
This commit is contained in:
Родитель
1f61ae43a0
Коммит
0fd7093a2d
|
@ -1553,13 +1553,6 @@ Engine.prototype = {
|
|||
* the engine object.
|
||||
*/
|
||||
_parseAsSherlock: function SRCH_ENG_parseAsSherlock() {
|
||||
/**
|
||||
* Trims leading and trailing whitespace from aStr.
|
||||
*/
|
||||
function sTrim(aStr) {
|
||||
return aStr.replace(/^\s+/g, "").replace(/\s+$/g, "");
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts one Sherlock "section" from aSource. A section is essentially
|
||||
* an HTML element with attributes, but each attribute must be on a new
|
||||
|
@ -1616,11 +1609,11 @@ Engine.prototype = {
|
|||
|
||||
var section = {};
|
||||
for (var i = 0; i < lines.length; i++) {
|
||||
var line = sTrim(lines[i]);
|
||||
var line = lines[i].trim();
|
||||
|
||||
var els = line.split("=");
|
||||
var name = sTrim(els.shift().toLowerCase());
|
||||
var value = sTrim(els.join("="));
|
||||
var name = els.shift().trim().toLowerCase();
|
||||
var value = els.join("=").trim();
|
||||
|
||||
if (!name || !value)
|
||||
continue;
|
||||
|
@ -1629,7 +1622,7 @@ Engine.prototype = {
|
|||
// value, and remove any trailing slashes or ">" characters
|
||||
value = value.replace(/^["']/, "")
|
||||
.replace(/["']\s*[\\\/]?>?\s*$/, "") || "";
|
||||
value = sTrim(value);
|
||||
value = value.trim();
|
||||
|
||||
// Don't clobber existing attributes
|
||||
if (!(name in section))
|
||||
|
@ -1747,7 +1740,7 @@ Engine.prototype = {
|
|||
lines.forEach(function (line) {
|
||||
// Strip leading/trailing whitespace and remove the surrounding markup
|
||||
// ("<input" and ">")
|
||||
line = sTrim(line).replace(/^<input/i, "").replace(/>$/, "");
|
||||
line = line.trim().replace(/^<input/i, "").replace(/>$/, "");
|
||||
|
||||
// If this is one of the "directional" inputs (<inputnext>/<inputprev>)
|
||||
const directionalInput = /^(prev|next)/i;
|
||||
|
|
Загрузка…
Ссылка в новой задаче