Skip to content
Permalink
Browse files

Single quoted string accepts double '' to express one quote [Closes #45]

  • Loading branch information
dg committed Jan 14, 2020
1 parent 9daa0c7 commit 53703908f8bfba98aeecdaba35c984c0a86f9563
Showing with 6 additions and 1 deletion.
  1. +4 −1 src/Neon/Decoder.php
  2. +2 −0 tests/Neon/Decoder.phpt
@@ -21,7 +21,7 @@ final class Decoder
'
\'\'\'\n (?:(?: [^\n] | \n(?![\t\ ]*+\'\'\') )*+ \n)?[\t\ ]*+\'\'\' |
"""\n (?:(?: [^\n] | \n(?![\t\ ]*+""") )*+ \n)?[\t\ ]*+""" |
\'[^\'\n]*+\' |
\' (?: \'\' | [^\'\n] )*+ \' |
" (?: \\\\. | [^"\\\\\n] )*+ "
',

@@ -268,6 +268,9 @@ private function parse($indent, array $result = null, $key = null, bool $hasKey
$converted = preg_replace('#^\n|\n[\t ]*+$#D', '', $converted);
} else {
$converted = substr($t, 1, -1);
if ($t[0] === "'") {
$converted = str_replace("''", "'", $converted);
}
}
if ($t[0] === '"') {
$converted = preg_replace_callback('#\\\\(?:ud[89ab][0-9a-f]{2}\\\\ud[c-f][0-9a-f]{2}|u[0-9a-f]{4}|x[0-9a-f]{2}|.)#i', [$this, 'cbString'], $converted);
@@ -43,6 +43,8 @@ $dataSet = [

// strings
["''", ''],
["'foo'", 'foo'],
["'fo''o'", "fo'o"],
['""', ''],
['"foo"', 'foo'],
['"f\\no"', "f\no"],

0 comments on commit 5370390

Please sign in to comment.
You can’t perform that action at this time.