mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-11 16:32:59 +00:00
Bug 488796 - form history should not save extremely large values. r=dolske, r=gavin
This commit is contained in:
parent
508e3cea04
commit
021c04ebfa
@ -72,6 +72,10 @@
|
||||
|
||||
#define PR_HOURS ((PRInt64)60 * 60 * 1000000)
|
||||
|
||||
// Limit the length of names and values stored in form history
|
||||
#define MAX_HISTORY_NAME_LEN 200
|
||||
#define MAX_HISTORY_VALUE_LEN 200
|
||||
|
||||
// nsFormHistoryResult is a specialized autocomplete result class that knows
|
||||
// how to remove entries from the form history table.
|
||||
class nsFormHistoryResult : public nsIAutoCompleteSimpleResult
|
||||
@ -514,8 +518,13 @@ nsFormHistory::Notify(nsIDOMHTMLFormElement* formElt, nsIDOMWindowInternal* aWin
|
||||
inputElt->GetName(name);
|
||||
if (name.IsEmpty())
|
||||
inputElt->GetId(name);
|
||||
if (!name.IsEmpty())
|
||||
AddEntry(name, value);
|
||||
|
||||
if (name.IsEmpty())
|
||||
continue;
|
||||
if (name.Length() > MAX_HISTORY_NAME_LEN ||
|
||||
value.Length() > MAX_HISTORY_VALUE_LEN)
|
||||
continue;
|
||||
AddEntry(name, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -66,6 +66,17 @@
|
||||
<button type="submit">Submit</button>
|
||||
</form>
|
||||
|
||||
<!-- input with name too long (300 chars.) -->
|
||||
<form id="form10" onsubmit="return checkSubmit(10)">
|
||||
<input type="text" name="12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890">
|
||||
<button type="submit">Submit</button>
|
||||
</form>
|
||||
|
||||
<!-- input with value too long (300 chars.) -->
|
||||
<form id="form11" onsubmit="return checkSubmit(11)">
|
||||
<input type="text" name="test1">
|
||||
<button type="submit">Submit</button>
|
||||
</form>
|
||||
|
||||
<!-- ===== Things that should be saved ===== -->
|
||||
|
||||
@ -113,6 +124,8 @@ function startTest() {
|
||||
is(input.type, "text", "checking we got unidentified input");
|
||||
input.value = "dontSaveThis";
|
||||
// Form 9 has nothing to modify.
|
||||
$_(10, "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890").value = "dontSaveThis";
|
||||
$_(11, "test1").value = "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890";
|
||||
|
||||
$_(101, "test1").value = "savedValue";
|
||||
$_(102, "test2").value = "savedValue";
|
||||
@ -144,6 +157,8 @@ function checkSubmit(formNum) {
|
||||
case 7:
|
||||
case 8:
|
||||
case 9:
|
||||
case 10:
|
||||
case 11:
|
||||
ok(!fh.hasEntries, "checking for empty storage");
|
||||
break;
|
||||
// The other tests do save data...
|
||||
@ -163,13 +178,13 @@ function checkSubmit(formNum) {
|
||||
|
||||
// End the test at the last form.
|
||||
if (formNum == 103) {
|
||||
is(numSubmittedForms, 12, "Ensuring all forms were submitted.");
|
||||
is(numSubmittedForms, 14, "Ensuring all forms were submitted.");
|
||||
SimpleTest.finish();
|
||||
return false; // return false to cancel current form submission
|
||||
}
|
||||
|
||||
// submit the next form.
|
||||
var button = getFormSubmitButton(formNum == 9 ? 101 : (formNum + 1));
|
||||
var button = getFormSubmitButton(formNum == 11 ? 101 : (formNum + 1));
|
||||
button.click();
|
||||
|
||||
return false; // cancel current form submission
|
||||
|
Loading…
Reference in New Issue
Block a user