From 572659f22154ef68b687b8c7f399021b5a99ad4c Mon Sep 17 00:00:00 2001 From: Deryck Hodge Date: Tue, 24 May 2005 17:33:47 +0000 Subject: r6958: Properly display quotes in SWAT. Thanks to Jay Fenlason for spotting this issue. deryck (This used to be commit cd12641383c50020104142cad0e705e2b58c50f4) --- source3/web/swat.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'source3') 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("", - make_parm_name(parm->label), utf8_s1); + make_parm_name(parm->label), fix_quotes(utf8_s1)); SAFE_FREE(utf8_s1); printf("", _("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("", - make_parm_name(parm->label), utf8_s1); + make_parm_name(parm->label), fix_quotes(utf8_s1)); SAFE_FREE(utf8_s1); printf("", _("Set Default"), make_parm_name(parm->label),fix_backslash((char *)(parm->def.svalue))); -- cgit