From: Ted Kremenek Date: Mon, 3 Nov 2008 07:44:16 +0000 (+0000) Subject: Simplify the functions HtmlEsape and ShellEscape. We now properly print out the... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=87f8de72a3c5d61736a14dca271504aaa5020d6f;p=clang Simplify the functions HtmlEsape and ShellEscape. We now properly print out the following command line in the HTML output: scan-build gcc -x c /dev/null -c -Dfoo='"string abc"' Fixes git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58600 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/utils/scan-build b/utils/scan-build index 41dd29ebaa..0d4bc90d06 100755 --- a/utils/scan-build +++ b/utils/scan-build @@ -932,9 +932,9 @@ sub HtmlEscape { # copy argument to new variable so we don't clobber the original my $arg = shift || ''; my $tmp = $arg; - - $tmp =~ s/([\<\>\'\"])/sprintf("&#%02x;", chr($1))/ge; - + $tmp =~ s/&/&/g; + $tmp =~ s//>/g; return $tmp; } @@ -945,11 +945,8 @@ sub HtmlEscape { sub ShellEscape { # copy argument to new variable so we don't clobber the original my $arg = shift || ''; - my $tmp = $arg; - - $tmp =~ s/([\!\;\\\'\"\`\<\>\|\s\(\)\[\]\?\#\$\^\&\*\=])/\\$1/g; - - return $tmp; + if ($arg =~ /["\s]/) { return "'" . $arg . "'"; } + return $arg; } ##----------------------------------------------------------------------------##