Open Bug 405890 Opened 17 years ago Updated 2 years ago

When getting a DOM element's href property, and when the href contains a space, the space is URLencoded as %20

Categories

(Core :: DOM: Core & HTML, defect, P5)

x86
Windows XP
defect

Tracking

()

UNCONFIRMED

People

(Reporter: bigfun, Unassigned)

Details

(Whiteboard: DUPEME)

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9b1) Gecko/2007110904 Firefox/3.0b1
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9b1) Gecko/2007110904 Firefox/3.0b1

This may sound like a trivial and even defensible bug, but it leads to incompatibilities when running some DHTML applications.  If a space is represented as a space on some browsers and as %20 in others, then string comparisons can fail in places where they wouldn't. In this code snippet:

if (these2children[k].href.indexOf(": addfield")>0)
						{
							these2children[k].href="javascript: addfield('addfield-" + OurNewNumber + "')";
							these2children[k].id="id" + "addfield-"  + OurNewNumber;
							
						}
fails to work correctly in Firefox 3.0b1 because the space is now %20.  The same code works correctly on older versions of Firefox and Internet Explorer 6 and 7.  (I haven't tried in Opera.)



Reproducible: Always

Steps to Reproduce:
1.create an href containing a space, such as <a id="id1" href="javascript: addfield(6)">
2. read the href in javascript
3. href is returned with "%20" instead of " "
Actual Results:  
20

Expected Results:  
[space]
My first search didn't find a bug that this is a direct duplicate of, but in spirit it's a duplicate of all the bugs talking about things like being surprised to get back an absolute URI when the href attribute had a relative URI - the DOM spec says .href is a URI, not the string you put in, and if you want the string you put in, you should .getAttribute("href") instead.
Component: General → DOM
Product: Firefox → Core
QA Contact: general → general
Whiteboard: DUPEME
https://bugzilla.mozilla.org/show_bug.cgi?id=1472046

Move all DOM bugs that haven’t been updated in more than 3 years and has no one currently assigned to P5.

If you have questions, please contact :mdaly.
Priority: -- → P5
Component: DOM → DOM: Core & HTML
Severity: minor → S4
You need to log in before you can comment on or make changes to this bug.