svn commit: samba r6957 - in trunk/source/web: .

deryck at samba.org deryck at samba.org
Tue May 24 17:33:26 GMT 2005


Author: deryck
Date: 2005-05-24 17:33:25 +0000 (Tue, 24 May 2005)
New Revision: 6957

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

Log:
Properly display quotes in SWAT. Thanks to Jay
Fenlason <fenlason at redhat.com> for spotting this issue.

deryck

Modified:
   trunk/source/web/swat.c


Changeset:
Modified: trunk/source/web/swat.c
===================================================================
--- trunk/source/web/swat.c	2005-05-24 13:31:22 UTC (rev 6956)
+++ trunk/source/web/swat.c	2005-05-24 17:33:25 UTC (rev 6957)
@@ -77,6 +77,26 @@
 	return newstring;
 }
 
+static char *fix_quotes(const char *str)
+{
+	static pstring newstring;
+	char *p = newstring;
+	size_t newstring_len = sizeof(newstring);
+	int quote_len = strlen("&quot;");
+
+	while (*str) {
+		if ( *str == '\"' && (newstring_len - PTR_DIFF(p, newstring) - 1) > quote_len ) {
+			strncpy( p, "&quot;", quote_len); 
+			p += 6;
+		} else {
+			*p++ = *str;
+		}
+		++str;
+	}
+	*p = '\0';
+	return newstring;
+}
+
 static char *stripspaceupper(const char *str)
 {
 	static char newstring[1024];
@@ -249,7 +269,7 @@
 	case P_USTRING:
 		push_utf8_allocate(&utf8_s1, *(char **)ptr);
 		printf("<input type=text size=30 name=\"parm_%s\" value=\"%s\">",
-		       make_parm_name(parm->label), utf8_s1);
+		       make_parm_name(parm->label), fix_quotes(utf8_s1));
 		SAFE_FREE(utf8_s1);
 		printf("<input type=button value=\"%s\" onClick=\"swatform.parm_%s.value=\'%s\'\">",
 			_("Set Default"), make_parm_name(parm->label),fix_backslash((char *)(parm->def.svalue)));
@@ -259,7 +279,7 @@
 	case P_UGSTRING:
 		push_utf8_allocate(&utf8_s1, (char *)ptr);
 		printf("<input type=text size=30 name=\"parm_%s\" value=\"%s\">",
-		       make_parm_name(parm->label), utf8_s1);
+		       make_parm_name(parm->label), fix_quotes(utf8_s1));
 		SAFE_FREE(utf8_s1);
 		printf("<input type=button value=\"%s\" onClick=\"swatform.parm_%s.value=\'%s\'\">",
 			_("Set Default"), make_parm_name(parm->label),fix_backslash((char *)(parm->def.svalue)));



More information about the samba-cvs mailing list