Active TopicsActive Topics  Display List of Forum MembersMemberlist  Search The ForumSearch  HelpHelp
  RegisterRegister  LoginLogin
PowerHome General
 PowerHome Messageboard : PowerHome General
Subject Topic: URL Encoding function Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
patrickm
Senior Member
Senior Member


Joined: February 22 2007
Location: United States
Online Status: Offline
Posts: 188
Posted: June 25 2012 at 23:18 | IP Logged Quote patrickm

Does anybody know of any PH functions that would do URL encoding?

ph_htmlescape() does some characters but not all possible/typical ASCII characters.

Patrick
Back to Top View patrickm's Profile Search for other posts by patrickm
 
MrGibbage
Super User
Super User
Avatar

Joined: October 23 2006
Location: United States
Online Status: Offline
Posts: 513
Posted: June 28 2012 at 07:40 | IP Logged Quote MrGibbage

This is a good question. I did some testing and ph_htmlescape does not seem to do anything with ascii control
characters such as CR/LF and TAB, which are valid characters in a URL when they are properly encoded. (%0d,
%0a, and %09).

Perhaps the misconception here is that ph_htmlescape is just that--an HTML escaper, not a URL escaper. Dave, I
think we really need a function for URL encoding. Right now I have to pipe everything I want to send to a web
server through something like this:
ph_htmlescape(ph_replaceall(ph_replaceall("{TEST}",CHAR(13), "%0d"),CHAR(10),"%0a"))

And that doesn't even take care of TAB characters or the also valid BACKSPACE character (why anyone would want
to send a backspace is beyond me, but nonetheless...)

__________________
Skip
Back to Top View MrGibbage's Profile Search for other posts by MrGibbage
 
dhoward
Admin Group
Admin Group
Avatar

Joined: June 29 2001
Location: United States
Online Status: Offline
Posts: 4447
Posted: June 28 2012 at 14:24 | IP Logged Quote dhoward

Hmmm...I checked the sourcecode and you're correct. Im not escaping CR/LF, tab, or BS characters. I also checked all instances where Im using this function internally and Im only using this to properly escape URL's. I don't use it anywhere to escape HTML sequences so I guess I originally intended for this function to be a URL escaper.

The characters that are currently escaped are:

%#<> "'&=?@:;/+

I can modify the current function to handle the extra characters. I don't think I need to add BS because there is no way that I know of to embed an actual BS character within a string so that I can even escape it. Of course you can include an already escaped backspace character within a string but I cant check for the existence of an unescaped BS character. Or I can add a new function with the additional characters escaped in case modifying the existing function would cause a problem for existing code. The new function could also include an additional parameter that would "control" what escape characters to search for. I'd probably need to do some research to see what characters need to be escaped for both URL's and general HTML to see how this extra parameter should be utilized.

In any event, I'll get the changes done in the next beta (which will hopefully be very soon with the I2CS changes) since its an easy mod.

Dave.
Back to Top View dhoward's Profile Search for other posts by dhoward Visit dhoward's Homepage
 
MrGibbage
Super User
Super User
Avatar

Joined: October 23 2006
Location: United States
Online Status: Offline
Posts: 513
Posted: June 28 2012 at 15:11 | IP Logged Quote MrGibbage

Dave, you are a Rock Star! Thanks!

I don't think I would ever miss BS, so do whatever you want with it.

__________________
Skip
Back to Top View MrGibbage's Profile Search for other posts by MrGibbage
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum