Skip to content

Commit 67b3422

Browse files
committed
Fix unescaped strings
1 parent d65d0a7 commit 67b3422

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/SDK/Language/HTTP.php

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,23 @@ public function getParamExample(array $param): string
154154
case self::TYPE_FILE:
155155
case self::TYPE_NUMBER:
156156
case self::TYPE_INTEGER:
157-
case self::TYPE_STRING:
158-
case self::TYPE_ARRAY:
159157
$output .= $example;
160158
break;
159+
case self::TYPE_ARRAY:
160+
// If array of strings, make sure any sub-strings are escaped
161+
if (\substr($example, 1, 1) === '"') {
162+
$start = \substr($example, 0, 2);
163+
$end = \substr($example, -2);
164+
$contents = \substr($example, 2, -2);
165+
$contents = \addslashes($contents);
166+
$output .= $start . $contents . $end;
167+
} else {
168+
$output .= $example;
169+
}
170+
break;
171+
case self::TYPE_STRING:
172+
$output .= '"' . \addslashes($example) . '"';
173+
break;
161174
case self::TYPE_BOOLEAN:
162175
$output .= ($example) ? 'true' : 'false';
163176
break;

0 commit comments

Comments
 (0)