Fixes for url_encode()

jeff vier boinger at tradingtechnologies.com
Mon Oct 25 18:04:34 CEST 2004


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




More information about the Developers mailing list