diff options
author | Deryck Hodge <deryck@samba.org> | 2005-05-24 17:33:47 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 10:56:58 -0500 |
commit | 572659f22154ef68b687b8c7f399021b5a99ad4c (patch) | |
tree | d4da2536d767fbe2d9421e4364d7a1b0a23a4e32 | |
parent | 48118680cb3ecee5f4db499502c083d309177552 (diff) | |
download | samba-572659f22154ef68b687b8c7f399021b5a99ad4c.tar.gz samba-572659f22154ef68b687b8c7f399021b5a99ad4c.tar.bz2 samba-572659f22154ef68b687b8c7f399021b5a99ad4c.zip |
r6958: Properly display quotes in SWAT. Thanks to Jay
Fenlason <fenlason@redhat.com> for spotting this issue.
deryck
(This used to be commit cd12641383c50020104142cad0e705e2b58c50f4)
-rw-r--r-- | source3/web/swat.c | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/source3/web/swat.c b/source3/web/swat.c index 1d6241fdd6..d7e4e72241 100644 --- a/source3/web/swat.c +++ b/source3/web/swat.c @@ -77,6 +77,26 @@ static char *fix_backslash(const char *str) 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("""); + + while (*str) { + if ( *str == '\"' && (newstring_len - PTR_DIFF(p, newstring) - 1) > quote_len ) { + strncpy( p, """, 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 @@ static void show_parameter(int snum, struct parm_struct *parm) case P_USTRING: push_utf8_allocate(&utf8_s1, *(char **)ptr); printf("<input type=text size=40 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 @@ static void show_parameter(int snum, struct parm_struct *parm) case P_UGSTRING: push_utf8_allocate(&utf8_s1, (char *)ptr); printf("<input type=text size=40 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))); |