|
Rainchild Wizard
Joined: 10 Oct 2000 Posts: 1551 Location: Australia
|
Posted: Tue Nov 16, 2004 1:20 am
String Library - URL Encode |
I was concerned in: http://forums.zuggsoft.com/mx/modules/mx_kb/kb.php?mode=doc&k=1176
that you said
Quote: |
Although the ASCII space character is listed as unsafe in this RFC, in practice a space is allowable in modern URLs. If you wish, you can convert spaces to '+' or '%20' codes using the str.Replace function:
str.Replace( Source, ' ', '+') or
str.Replace( Source, ' ', '%20')
|
Given that IE still uses %20 to this day, I think doing a second replace on a string after encoding the URL is scanning the string 2x... I guess URLs are usually small, but its the principal of the thing ;)
You should have another URL encode which does the %20 by default :) |
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Tue Nov 16, 2004 1:25 am |
Can someone verify this? I can't think of a URL that uses a space in it off the top of my head, but I'm pretty sure that even IE allows spaces in URLs these days.
But in general, since this is a scripting language, scanning a string twice like a URL isn't a huge deal. If you want speed then you just write your own function that does both at once. I don't really feel a huge need to add yet another function or option for this. But if browsers still don't allow spaces these days, then I'll go ahead and convert spaces to %20 by default.
If someone has a URL with a space in it that can be used for testing, let me know. |
|
|
|
Krule Adept
Joined: 12 Nov 2000 Posts: 268 Location: Canada
|
Posted: Tue Nov 16, 2004 4:48 am |
Url with spaces:
[url]http://krule.net/oldpics/pics/Books and Books.jpg[/url]
Firefox automagically translates it to this:
http://krule.net/oldpics/pics/Books%20and%20Books.jpg
(Thats a small fraction of the books in my room atm..heh) |
|
|
|
Vijilante SubAdmin
Joined: 18 Nov 2001 Posts: 5182
|
Posted: Tue Nov 16, 2004 11:11 am |
IE also converted this to %20
|
|
_________________ The only good questions are the ones we have never answered before.
Search the Forums |
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Tue Nov 16, 2004 6:04 pm |
Right. They convert it, but it still works. If you copy/paste it into IE it works. I guess the real test is to see if it works in a low-level HTTP GET request or not. I'll test this with the zApp stuff and find out.
|
|
|
|
|
|