svn commit: samba r23527 - in branches: SAMBA_3_0/source/client SAMBA_3_0_25/source/client SAMBA_3_0_26/source/client

idra at samba.org idra at samba.org
Sat Jun 16 22:52:52 GMT 2007


Author: idra
Date: 2007-06-16 22:52:51 +0000 (Sat, 16 Jun 2007)
New Revision: 23527

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=23527

Log:

Use existing escaping function pointed by James


Modified:
   branches/SAMBA_3_0/source/client/smbspool.c
   branches/SAMBA_3_0_25/source/client/smbspool.c
   branches/SAMBA_3_0_26/source/client/smbspool.c


Changeset:
Modified: branches/SAMBA_3_0/source/client/smbspool.c
===================================================================
--- branches/SAMBA_3_0/source/client/smbspool.c	2007-06-16 19:58:17 UTC (rev 23526)
+++ branches/SAMBA_3_0/source/client/smbspool.c	2007-06-16 22:52:51 UTC (rev 23527)
@@ -603,35 +603,11 @@
 
 static char *uri_unescape_alloc(const char *uritok)
 {
-	char *t, *ret;
-	const char *p;
-	long int val;
-	char eval[3];
+	char *ret;
 
-	ret = (char *)SMB_MALLOC(strlen(uritok)+1);
-
+	ret = (char *)SMB_STRDUP(uritok);
 	if (!ret) return NULL;
 
-	eval[2] = '\0';
-
-	for (p = uritok, t = ret; *p; p++, t++) {
-		if (*p == '%') { /* unescape hex */
-			p++;
-			eval[0] = *p;
-			p++;
-			eval[1] = *p;
-			val = strtol(eval, NULL, 16);
-			if ((val == LONG_MIN || val == LONG_MAX) && errno == ERANGE) {
-				SAFE_FREE(ret);
-				return NULL;
-			}
-			*t = (char)val;
-		} else {
-			*t = *p;
-		}
-	}
-
-	*t = '\0'; /*terminate*/
-
+	rfc1738_unescape(ret);
 	return ret;
 }

Modified: branches/SAMBA_3_0_25/source/client/smbspool.c
===================================================================
--- branches/SAMBA_3_0_25/source/client/smbspool.c	2007-06-16 19:58:17 UTC (rev 23526)
+++ branches/SAMBA_3_0_25/source/client/smbspool.c	2007-06-16 22:52:51 UTC (rev 23527)
@@ -603,35 +603,11 @@
 
 static char *uri_unescape_alloc(const char *uritok)
 {
-	char *t, *ret;
-	const char *p;
-	long int val;
-	char eval[3];
+	char *ret;
 
-	ret = (char *)SMB_MALLOC(strlen(uritok)+1);
-
+	ret = (char *)SMB_STRDUP(uritok);
 	if (!ret) return NULL;
 
-	eval[2] = '\0';
-
-	for (p = uritok, t = ret; *p; p++, t++) {
-		if (*p == '%') { /* unescape hex */
-			p++;
-			eval[0] = *p;
-			p++;
-			eval[1] = *p;
-			val = strtol(eval, NULL, 16);
-			if ((val == LONG_MIN || val == LONG_MAX) && errno == ERANGE) {
-				SAFE_FREE(ret);
-				return NULL;
-			}
-			*t = (char)val;
-		} else {
-			*t = *p;
-		}
-	}
-
-	*t = '\0'; /*terminate*/
-
+	rfc1738_unescape(ret);
 	return ret;
 }

Modified: branches/SAMBA_3_0_26/source/client/smbspool.c
===================================================================
--- branches/SAMBA_3_0_26/source/client/smbspool.c	2007-06-16 19:58:17 UTC (rev 23526)
+++ branches/SAMBA_3_0_26/source/client/smbspool.c	2007-06-16 22:52:51 UTC (rev 23527)
@@ -603,35 +603,11 @@
 
 static char *uri_unescape_alloc(const char *uritok)
 {
-	char *t, *ret;
-	const char *p;
-	long int val;
-	char eval[3];
+	char *ret;
 
-	ret = (char *)SMB_MALLOC(strlen(uritok)+1);
-
+	ret = (char *)SMB_STRDUP(uritok);
 	if (!ret) return NULL;
 
-	eval[2] = '\0';
-
-	for (p = uritok, t = ret; *p; p++, t++) {
-		if (*p == '%') { /* unescape hex */
-			p++;
-			eval[0] = *p;
-			p++;
-			eval[1] = *p;
-			val = strtol(eval, NULL, 16);
-			if ((val == LONG_MIN || val == LONG_MAX) && errno == ERANGE) {
-				SAFE_FREE(ret);
-				return NULL;
-			}
-			*t = (char)val;
-		} else {
-			*t = *p;
-		}
-	}
-
-	*t = '\0'; /*terminate*/
-
+	rfc1738_unescape(ret);
 	return ret;
 }



More information about the samba-cvs mailing list