Module Name:    src
Committed By:   plunky
Date:           Mon Nov 23 10:08:47 UTC 2009

Modified Files:
        src/lib/libc/gen: vis.c

Log Message:
fix VIS_HTTPSTYLE to not convert "safe" ($-_.+) and "extra" (!*'(),)
characters as mentioned in rfc1738 and rfc1808 and, I think intended
all along in this code but the logic was inverted.

Don't use strchr as it also matches the NUL character which we want
to escape, just compare against the chars directly as done in the
FreeBSD code.


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/lib/libc/gen/vis.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/gen/vis.c
diff -u src/lib/libc/gen/vis.c:1.40 src/lib/libc/gen/vis.c:1.41
--- src/lib/libc/gen/vis.c:1.40	Wed Feb 11 13:52:28 2009
+++ src/lib/libc/gen/vis.c	Mon Nov 23 10:08:47 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: vis.c,v 1.40 2009/02/11 13:52:28 christos Exp $	*/
+/*	$NetBSD: vis.c,v 1.41 2009/11/23 10:08:47 plunky Exp $	*/
 
 /*-
  * Copyright (c) 1989, 1993
@@ -57,7 +57,7 @@
 
 #include <sys/cdefs.h>
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: vis.c,v 1.40 2009/02/11 13:52:28 christos Exp $");
+__RCSID("$NetBSD: vis.c,v 1.41 2009/11/23 10:08:47 plunky Exp $");
 #endif /* LIBC_SCCS and not lint */
 
 #include "namespace.h"
@@ -120,13 +120,20 @@
 static char *
 do_hvis(char *dst, int c, int flag, int nextc, const char *extra)
 {
-	if (!isascii(c) || !isalnum(c) || strchr("$-_.+!*'(),", c) != NULL) {
+
+	if ((isascii(c) && isalnum(c))
+	    /* safe */
+	    || c == '$' || c == '-' || c == '_' || c == '.' || c == '+'
+	    /* extra */
+	    || c == '!' || c == '*' || c == '\'' || c == '(' || c == ')'
+	    || c == ',') {
+		dst = do_svis(dst, c, flag, nextc, extra);
+	} else {
 		*dst++ = '%';
 		*dst++ = xtoa(((unsigned int)c >> 4) & 0xf);
 		*dst++ = xtoa((unsigned int)c & 0xf);
-	} else {
-		dst = do_svis(dst, c, flag, nextc, extra);
 	}
+
 	return dst;
 }
 

Reply via email to