mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 657702 - Remove leading and trailing whitespaces in <input type='email'> value sanitizing algorithm. r=smaug
This commit is contained in:
parent
385690f551
commit
4efa316d84
@ -2510,12 +2510,12 @@ nsHTMLInputElement::SanitizeValue(nsAString& aValue)
|
||||
case NS_FORM_INPUT_SEARCH:
|
||||
case NS_FORM_INPUT_TEL:
|
||||
case NS_FORM_INPUT_PASSWORD:
|
||||
case NS_FORM_INPUT_EMAIL:
|
||||
{
|
||||
PRUnichar crlf[] = { PRUnichar('\r'), PRUnichar('\n'), 0 };
|
||||
aValue.StripChars(crlf);
|
||||
}
|
||||
break;
|
||||
case NS_FORM_INPUT_EMAIL:
|
||||
case NS_FORM_INPUT_URL:
|
||||
{
|
||||
PRUnichar crlf[] = { PRUnichar('\r'), PRUnichar('\n'), 0 };
|
||||
|
@ -75,8 +75,12 @@ var email = document.forms[0].elements[0];
|
||||
var values = [
|
||||
[ '', true ], // The empty string shouldn't be considered as invalid.
|
||||
[ 'foo@bar.com', true ],
|
||||
[ ' foo@bar.com', false ],
|
||||
[ 'foo@bar.com ', false ],
|
||||
[ ' foo@bar.com', true ],
|
||||
[ 'foo@bar.com ', true ],
|
||||
[ '\r\n foo@bar.com', true ],
|
||||
[ 'foo@bar.com \n\r', true ],
|
||||
[ '\n\n \r\rfoo@bar.com\n\n \r\r', true ],
|
||||
[ '\n\r \n\rfoo@bar.com\n\r \n\r', true ],
|
||||
[ 'tulip', false ],
|
||||
// Some checks on the user part of the address.
|
||||
[ '@bar.com', false ],
|
||||
@ -163,7 +167,7 @@ values.push(["foo@bar.com" + legalCharacters, true]);
|
||||
// Add domain illegal characters.
|
||||
illegalCharacters = "()<>[]:;@\\,!#$%&'*+/=?^_`{|}~ \t";
|
||||
for each (c in illegalCharacters) {
|
||||
values.push(['foo@foo.bar' + c, false]);
|
||||
values.push(['foo@foo.ba' + c + 'r', false]);
|
||||
}
|
||||
|
||||
values.forEach(function([value, valid]) {
|
||||
|
@ -47,9 +47,9 @@ function sanitizeValue(aType, aValue)
|
||||
case "password":
|
||||
case "search":
|
||||
case "tel":
|
||||
case "email":
|
||||
return aValue.replace(/[\n\r]/g, "");
|
||||
case "url":
|
||||
case "email":
|
||||
return aValue.replace(/[\n\r]/g, "").replace(/^\s+|\s+$/g, "");
|
||||
case "date":
|
||||
case "month":
|
||||
|
Loading…
Reference in New Issue
Block a user