Closed
Bug 293695
Opened 20 years ago
Closed 19 years ago
JavaScript (JS) security error when trying to set value for a input file field
Categories
(Firefox :: Security, defect)
Tracking
()
RESOLVED
DUPLICATE
of bug 266744
People
(Reporter: frank, Unassigned)
Details
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.7) Gecko/20050414 Firefox/1.0.3
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.7) Gecko/20050414 Firefox/1.0.3
When I try to use JS to set a file input field, JavaScript Console return the
following error:
Error: uncaught exception: [Exception... "Security error" code: "1000"
nsresult: "0x805303e8 (NS_ERROR_DOM_SECURITY_ERR)" location:
"file:///d:/abc.html Line: 90"]
Reproducible: Always
Steps to Reproduce:
The script/html I was using are as follows:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Page</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script langage="javascript">
<!--
function ck(e){
alert(e.value);
e.value = null;
}
//-->
</script>
</head>
<body>
<form action="" method="post" enctype="multipart/form-data" name="form2" id="form2">
<input name="file" type="file" size="25" onClick="ck(this);"/>
<input id="subphoto" name="submit" type="submit" value="Upload" />
</form>
</div>
</body>
</html>
Actual Results:
The file field doesn't reset, but return the error as described above.
Expected Results:
Running the html under IE, it clears the file field fine.
I'm not sure it's a bug or some sort of the security restriction, would there be
any work around then?
Comment 1•20 years ago
|
||
See
http://lxr.mozilla.org/mozilla/source/content/html/content/src/nsHTMLInputElement.cpp#646
You need to set the value to an empty string, anything else (including null) is
disallowed.
Even I use e.value = ''; or e.value = new String; instead of e.value = null;
same error persists. Any idea?
Comment 3•19 years ago
|
||
I should have realized this was fixed after 1.0.x in bug 266744. This works in Firefox 1.5.
*** This bug has been marked as a duplicate of 266744 ***
Status: UNCONFIRMED → RESOLVED
Closed: 19 years ago
Resolution: --- → DUPLICATE
You need to log in
before you can comment on or make changes to this bug.
Description
•