Fixes for url_encode()

Ethan Galstad nagios at nagios.org
Tue Oct 26 01:17:12 CEST 2004


Looks like RFC1738 provides a bit more detail.  I found an online url 
encoding tester that used the RFC specs to produce output - sure 
enough, dashes and underscores are not encoded in URLs.  I'll get 
this patch applied.

On 25 Oct 2004 at 11:04, jeff vier wrote:

> 
> I actually found I had problems (with Apan, primarily) if I didn't
> skip underscores and hyphens, as well.  Don't know about the RFC
> adherence, though.
> 
> Here's my diff against the current CVS:
> 
> ---------------
> Index: cgi/cgiutils.c
> ===================================================================
> RCS file: /cvsroot/nagios/nagios/cgi/cgiutils.c,v retrieving revision
> 1.38 diff -u -r1.38 cgiutils.c --- cgi/cgiutils.c      25 Oct 2004
> 05:05:54 -0000      1.38 +++ cgi/cgiutils.c      25 Oct 2004 15:56:42
> -0000 @@ -1291,8 +1291,8 @@
>                         break;
>                         }
> 
> -               /* alpha-numeric characters and dots don't get encoded
> */ -               else if(((char)input[x]>='0' &&
> (char)input[x]<='9') || ((char)input[x]>='A' && (char)input[x]<='Z')
> || ((char)input[x]>=(char)'a' && (char)input[x]<=(char)'z') ||
> (char)input[x]==(char)'.'){ +               /* alpha-numeric
> characters, dots, underscores, and hyphens don't get encoded */ +     
>          else if(((char)input[x]>='0' && (char)input[x]<='9') ||
> ((char)input[x]>='A' && (char)input[x]<='Z') ||
> ((char)input[x]>=(char)'a' && (char)input[x]<=(char)'z') ||
> (char)input[x]==(char)'.' || (char)input[x]=='_' ||
> (char)input[x]=='-'){
>                         encoded_url_string[y]=input[x];
>                         y++;
>                         }
> ----------------------
> 
> On Sat, 2004-10-23 at 12:21 +0200, Andreas Ericsson wrote:
> > In the original CVS version of url_encode() only alphanumerical
> > characters were left unencoded. This is in violation of RFC1866,
> > which also excludes dots from url encoding schemes.
> > 
> > Standards compliant browsers (such as Mozilla Firefox) may
> > experience problems with url encoded dots.
> > 
> > This patch includes dots ('.') in the characters not being url
> > encoded and thus fixes the problem.
> > 
> > Plain text document attachment (nagios-cgi-url_encode.diff)
> > diff -urN ../Nagios/cgi/cgiutils.c ./cgi/cgiutils.c
> > --- ../Nagios/cgi/cgiutils.c	Fri Oct 22 18:51:31 2004
> > +++ ./cgi/cgiutils.c	Sat Oct 23 12:17:54 2004
> > @@ -1291,8 +1291,8 @@
> >  			break;
> >  		        }
> >  
> > -		/* alpha-numeric characters don't get encoded */
> > -		else if(((char)input[x]>='0' && (char)input[x]<='9') ||
> > ((char)input[x]>='A' && (char)input[x]<='Z') ||
> > ((char)input[x]>=(char)'a' && (char)input[x]<=(char)'z')){
> > +		/* alpha-numeric characters and dots don't get encoded */
> > +		else if(((char)input[x]>='0' && (char)input[x]<='9') ||
> > +((char)input[x]>='A' && (char)input[x]<='Z') ||
> > +((char)input[x]>=(char)'a' && (char)input[x]<=(char)'z') ||
> > +(char)input[x]==(char)'.'){
> >  			encoded_url_string[y]=input[x];
> >  			y++;
> >  		        }
> 
> 
> 
> -------------------------------------------------------
> This SF.net email is sponsored by: IT Product Guide on
> ITManagersJournal Use IT products in your business? Tell us what you
> think of them. Give us Your Opinions, Get Free ThinkGeek Gift
> Certificates! Click to find out more
> http://productguide.itmanagersjournal.com/guidepromo.tmpl
> _______________________________________________ Nagios-devel mailing
> list Nagios-devel at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/nagios-devel
> 
> 



Ethan Galstad,
Nagios Developer
---
Email: nagios at nagios.org
Website: http://www.nagios.org



-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal
Use IT products in your business? Tell us what you think of them. Give us
Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
http://productguide.itmanagersjournal.com/guidepromo.tmpl




More information about the Developers mailing list