Gossamer Forum
Home : Products : Gossamer Links : Discussions :

[FIX] Eliminating the %2F codes from URL, and using the / sign unencoded

Quote Reply
[FIX] Eliminating the %2F codes from URL, and using the / sign unencoded
If you also hate the encoded / signs in the URL, which will result ugly URL in your browser, then you can ignore it with this modification.

Add the line highlighted with red to the sub escape in admin/GT/CGI.pm .

Original code (LSQL v2.1.1):
Code:
sub escape {
#--------------------------------------------------------------------------------
# return the url encoded string of the passed argument
#
my $toencode = pop;
return unless defined $toencode;
$toencode =~ s/([^\w.-])/sprintf("%%%02X",ord($1))/eg;
return $toencode;
}

Modified code (added code highlighted with red)
Code:
sub escape {
#--------------------------------------------------------------------------------
# return the url encoded string of the passed argument
#
my $toencode = pop;
return unless defined $toencode;
$toencode =~ s/([^\w.-])/sprintf("%%%02X",ord($1))/eg;
$toencode =~ s/\%2F/\//g; # decodes back the %2F back to /
return $toencode;
}
For the v2.1.0 version the modification is similar, but you should only insert the red line, because there was some other changes, in the v2.1.1 version upgrade.

There is not known any disagvantage of the change. I'm using this way on my own website since more than 1 year, and there was not problems with that.
If somebody knows or finds any disadvantage of it, let me know.

Have a nice day! Cool

Best regards,
Webmaster33


Paid Support
from Webmaster33. Expert in Perl programming & Gossamer Threads applications. (click here for prices)
Webmaster33's products (upd.2004.09.26) | Private message | Contact me | Was my post helpful? Donate my help...
Quote Reply
Re: [webmaster33] [FIX] Eliminating the %2F codes from URL, and using the / sign unencoded In reply to
RFC 1738....

>>
Only alphanumerics

[0-9a-zA-Z]

....the special characters

$-_.+!*'(),

and reserved characters used for their reserved purposes may be used unencoded within a URL."
<<
Quote Reply
Re: [Paul] [FIX] Eliminating the %2F codes from URL, and using the / sign unencoded In reply to
Hmm, yes, fine info. Thanks.
Anyway, if RFC 1738 says that, I accept it, that's the standard.

However, as I told I use the / unencoded in URL, in parameter values since a long time, and I had no problem with this.

Best regards,
Webmaster33


Paid Support
from Webmaster33. Expert in Perl programming & Gossamer Threads applications. (click here for prices)
Webmaster33's products (upd.2004.09.26) | Private message | Contact me | Was my post helpful? Donate my help...
Quote Reply
Re: [webmaster33] [FIX] Eliminating the %2F codes from URL, and using the / sign unencoded In reply to
>>
However, as I told I use the / unencoded in URL, in parameter values since a long time, and I had no problem with this.
<<

I wasn't disagreeing.
Quote Reply
Re: [Paul] [FIX] Eliminating the %2F codes from URL, and using the / sign unencoded In reply to
Wouldn't the '/' be a reserved character? It's a fundamental part of a URL, and should not be messed with.

Just looked at RFC 1738:

Quote:
Reserved:

Many URL schemes reserve certain characters for a special meaning:
their appearance in the scheme-specific part of the URL has a
designated semantics. If the character corresponding to an octet is
reserved in a scheme, the octet must be encoded. The characters ";",
"/", "?", ":", "@", "=" and "&" are the characters which may be
reserved for special meaning within a scheme. No other characters may
be reserved within a scheme.

Usually a URL has the same interpretation when an octet is
represented by a character and when it encoded. However, this is not
true for reserved characters: encoding a character reserved for a
particular scheme may change the semantics of a URL.

Thus, only alphanumerics, the special characters "$-_.+!*'(),", and
reserved characters used for their reserved purposes may be used
unencoded within a URL.

On the other hand, characters that are not required to be encoded
(including alphanumerics) may be encoded within the scheme-specific
part of a URL, as long as they are not being used for a reserved
purpose.


PUGDOG´┐Ż Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [pugdog] [FIX] Eliminating the %2F codes from URL, and using the / sign unencoded In reply to
Thanks for the info.

The "/" is basic part of URL. But if let we say we use it as argument or as parameter value, then my opinion is that it is not required to be encoded.

When we use "/" as a script argument after "?", or as parameter value, "/" has nothing special meaning, just a non-reserved character, and does not need encoding.

Best regards,
Webmaster33


Paid Support
from Webmaster33. Expert in Perl programming & Gossamer Threads applications. (click here for prices)
Webmaster33's products (upd.2004.09.26) | Private message | Contact me | Was my post helpful? Donate my help...