mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-19 01:10:22 +00:00
Bug 1057137 - Broken menu: NS_ERROR_ILLEGAL_VALUE: id, attribute, or value too long. r=enn
This commit is contained in:
parent
2dd71379b0
commit
4e2bdf4c74
@ -201,8 +201,14 @@ XULStore.prototype = {
|
||||
}
|
||||
|
||||
// bug 319846 -- don't save really long attributes or values.
|
||||
if (id.length > 1024 || attr.length > 1024 || value.length > 1024)
|
||||
throw Components.Exception("id, attribute, or value too long", Cr.NS_ERROR_ILLEGAL_VALUE);
|
||||
if (id.length > 512 || attr.length > 512) {
|
||||
throw Components.Exception("id or attribute name too long", Cr.NS_ERROR_ILLEGAL_VALUE);
|
||||
}
|
||||
|
||||
if (value.length > 4096) {
|
||||
Services.console.logStringMessage("XULStore: Warning, truncating long attribute value")
|
||||
value = value.substr(0, 4096);
|
||||
}
|
||||
|
||||
let obj = this._data;
|
||||
if (!(docURI in obj)) {
|
||||
|
@ -97,6 +97,21 @@ add_task(function* testImport(){
|
||||
checkOldStore();
|
||||
});
|
||||
|
||||
add_task(function* testTruncation() {
|
||||
let dos = Array(8192).join("~");
|
||||
// Long id names should trigger an exception
|
||||
Assert.throws(() => XULStore.setValue(browserURI, dos, "foo", "foo"), /NS_ERROR_ILLEGAL_VALUE/);
|
||||
|
||||
// Long attr names should trigger an exception
|
||||
Assert.throws(() => XULStore.setValue(browserURI, "foo", dos, "foo"), /NS_ERROR_ILLEGAL_VALUE/);
|
||||
|
||||
// Long values should be truncated
|
||||
XULStore.setValue(browserURI, "dos", "dos", dos);
|
||||
dos =XULStore.getValue(browserURI, "dos", "dos");
|
||||
do_check_true(dos.length == 4096)
|
||||
XULStore.removeValue(browserURI, "dos", "dos")
|
||||
});
|
||||
|
||||
add_task(function* testGetValue() {
|
||||
// Get non-existing property
|
||||
checkValue(browserURI, "side-window", "height", "");
|
||||
|
Loading…
x
Reference in New Issue
Block a user