summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--itjs.class2
-rwxr-xr-xtests/itjs.t6
2 files changed, 6 insertions, 2 deletions
diff --git a/itjs.class b/itjs.class
index 79158f6..e8284ce 100644
--- a/itjs.class
+++ b/itjs.class
@@ -85,7 +85,7 @@ static function encode($values)
if ($texts[2])
{
if ($jskeyword[$key] || !preg_match('/^[a-z_]\w*$/i', $key))
- $key = "'$key'";
+ $key = "'" . addslashes($key) . "'";
$result .= "$key:";
}
diff --git a/tests/itjs.t b/tests/itjs.t
index f616ced..4fcc9b4 100755
--- a/tests/itjs.t
+++ b/tests/itjs.t
@@ -47,4 +47,8 @@ is(
'keywords'
);
-?>
+is(
+ itjs::serialize(array("foo'foo" => "bar")),
+ "{'foo\'foo':\"bar\"}",
+ "quote ' in keys",
+);