Page MenuHomePhabricator

D7323.diff

diff --git a/src/lexer/PhutilLexer.php b/src/lexer/PhutilLexer.php
--- a/src/lexer/PhutilLexer.php
+++ b/src/lexer/PhutilLexer.php
@@ -226,6 +226,7 @@
while ($position < $length) {
$state_rules = idx($rules, end($states), array());
foreach ($state_rules as $rule) {
+
$matches = null;
if (!preg_match($rule[0], $input, $matches, 0, $position)) {
continue;
diff --git a/src/lexer/PhutilSimpleOptionsLexer.php b/src/lexer/PhutilSimpleOptionsLexer.php
--- a/src/lexer/PhutilSimpleOptionsLexer.php
+++ b/src/lexer/PhutilSimpleOptionsLexer.php
@@ -78,11 +78,13 @@
array('[^\'\\\\]+', 'word'),
array("'", "'", '!pop'),
array('\\\\.', 'esc'),
+ array('\\\\$', '!pop'),
),
'string2' => array(
array('[^"\\\\]+', 'word'),
array('"', '"', '!pop'),
array('\\\\.', 'esc'),
+ array('\\\\$', '!pop'),
),
);
}
diff --git a/src/parser/__tests__/PhutilSimpleOptionsTestCase.php b/src/parser/__tests__/PhutilSimpleOptionsTestCase.php
--- a/src/parser/__tests__/PhutilSimpleOptionsTestCase.php
+++ b/src/parser/__tests__/PhutilSimpleOptionsTestCase.php
@@ -80,6 +80,25 @@
}
}
+ public function testSimpleOptionsUnterminatedStrings() {
+ $list = array(
+ '"',
+ "'",
+ 'a="',
+ "a='",
+ 'a="\\',
+ "a='\\",
+ );
+
+ foreach ($list as $input) {
+ $parser = new PhutilSimpleOptions();
+ $this->assertEqual(
+ array(),
+ $parser->parse($input),
+ "Correct failing parse of invalid input: {$input}");
+ }
+ }
+
public function testSimpleOptionsUnparse() {
$map = array(
'' => array(),

File Metadata

Mime Type
text/x-diff
Storage Engine
amazon-s3
Storage Format
Raw Data
Storage Handle
phabricator/uf/uf/z3eebgtkcmycjzdq
Default Alt Text
D7323.diff (1 KB)

Event Timeline