diff options
author | Deryck Hodge <deryck@samba.org> | 2005-05-24 17:33:47 +0000 |
---|---|---|
committer | Deryck Hodge <deryck@samba.org> | 2005-05-24 17:33:47 +0000 |
commit | a6233439b2debf537de91b80bf569abfa7f4cfca (patch) | |
tree | 4e9e64de55c1528c6080bae20db4633bda3c2089 /source/web/swat.c | |
parent | e23b151005ea492ebaf570cca8254ff024be6fb3 (diff) | |
download | samba-a6233439b2debf537de91b80bf569abfa7f4cfca.tar.gz samba-a6233439b2debf537de91b80bf569abfa7f4cfca.tar.xz samba-a6233439b2debf537de91b80bf569abfa7f4cfca.zip |
r6958: Properly display quotes in SWAT. Thanks to Jay
Fenlason <fenlason@redhat.com> for spotting this issue.
deryck
Diffstat (limited to 'source/web/swat.c')
-rw-r--r-- | source/web/swat.c | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/source/web/swat.c b/source/web/swat.c index 1d6241fdd65..d7e4e722412 100644 --- a/source/web/swat.c +++ b/source/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))); |