lanmind Posted July 21, 2009 Share Posted July 21, 2009 Hello,I have some user submitted data that becomes part of a html file name and so in turn will be displayed as a URL across different browsers. I allow the submitted data to contain the URL illegal space character. When I submit it using my Firefox browser the space is automatically encoded to a "+". I'm not sure if this happens with every browser so I'm wondering if I need to encode any space characters before sending them to my server script.Thank you for your time. Link to comment Share on other sites More sharing options...
Guest FirefoxRocks Posted July 21, 2009 Share Posted July 21, 2009 JavaScript has an encode URI function: http://w3schools.com/jsref/jsref_encodeURI.asp Link to comment Share on other sites More sharing options...
lanmind Posted July 21, 2009 Author Share Posted July 21, 2009 I'm sorry I worded my question wrong. What I wanted to ask was:Do you think I need to URL encode space characters as they are illegal in URLs?I figured that I do because if a user submits "user name" it will become part of the html file name like so: user name.html. Of course spaces are illegal in URLs so the address http://www.example.com/userpages/user name.html would return a 404 error.Thank you. Link to comment Share on other sites More sharing options...
Synook Posted July 21, 2009 Share Posted July 21, 2009 + is the correct substitution for a space. Link to comment Share on other sites More sharing options...
Guest FirefoxRocks Posted July 21, 2009 Share Posted July 21, 2009 + is the correct substitution for a space.What about %20? Link to comment Share on other sites More sharing options...
Synook Posted July 21, 2009 Share Posted July 21, 2009 For paths, yes, but for form fields, + is the convention, and all browsers will encode it like that. I'm sure there's a reason somewhere. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.