Skip to content

Commit

Permalink
Only quote User object parms, not other Raw properties
Browse files Browse the repository at this point in the history
  • Loading branch information
nwsw committed Jan 19, 2016
1 parent e645777 commit a7aa3ab
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
5 changes: 4 additions & 1 deletion lib/obj_NWC2ClipItem.inc
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -101,7 +101,10 @@ function ReconstructClipText()
if (is_string($v)) { if (is_string($v)) {
// First encode all but '|' as cslashes, then convert \ and | to special combinations // First encode all but '|' as cslashes, then convert \ and | to special combinations
$v2 = str_replace(array('\\\\','|'), array('\]','\}'),addcslashes($v,"\r\n\t\\\"\'")); $v2 = str_replace(array('\\\\','|'), array('\]','\}'),addcslashes($v,"\r\n\t\\\"\'"));
if (($c == NWC2OPT_TEXT) || (($c == NWC2OPT_RAW) && preg_match('/[\s"\'\|\\\\]/',$v2))) if ($c == NWC2OPT_TEXT)
$s .= "\"$v2\"";
else if (!empty($this->UserType) && preg_match('/[\s"\'\|\\\\]/',$v2))
// this is not really necessary, but is done to match NWC behaviour
$s .= "\"$v2\""; $s .= "\"$v2\"";
else else
$s .= $v2; $s .= $v2;
Expand Down
10 changes: 7 additions & 3 deletions nwsw_TestLib.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@


foreach ($clip->Items as $item) { foreach ($clip->Items as $item) {
$o = new NWC2ClipItem($item); $o = new NWC2ClipItem($item);
echo "Ref: $item";
echo "New: ".$o->ReconstructClipText()."\n"; if ($o->IsContextInfo()) continue;
unset($o);
$origLine = trim($item);
$newLine = $o->ReconstructClipText();

if ($newLine != $origLine) echo "Ref: $origLine\nNew: $newLine\n\n";
} }


$usermsg = <<<__EOMSG $usermsg = <<<__EOMSG
Expand Down

0 comments on commit a7aa3ab

Please sign in to comment.