From a24ca62c9e78d96ac215d062fe87147a10d07e52 Mon Sep 17 00:00:00 2001 From: Leonel Quinteros Date: Tue, 11 Jul 2017 10:52:34 -0300 Subject: [PATCH] Fix escaping check. Fixes #8 --- src/Toml.php | 4 ++-- travis-test/example.toml | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Toml.php b/src/Toml.php index bef1d41..dd91bca 100755 --- a/src/Toml.php +++ b/src/Toml.php @@ -368,12 +368,12 @@ class Toml $openLString = !$openLString; } } - elseif($toml[$i] == "\\" && !in_array($toml[$i+1], array('b', 't', 'n', 'f', 'r', 'u', 'U', '"', "\\", ' '))) + elseif($toml[$i] == "\\" && $toml[$i-1] != "\\" && !in_array($toml[$i+1], array('b', 't', 'n', 'f', 'r', 'u', 'U', '"', "\\", ' '))) { // Reserved special characters inside strings should produce error if($openString) { - throw new Exception('Reserved special characters inside strings are not allowed: ' . $toml[$i] . $toml[$i+1]); + throw new Exception('Reserved special characters inside strings are not allowed: ' . $toml[$i] . $toml[$i+1]); } // Cleanup escaped new lines and whitespaces from multi-line strings diff --git a/travis-test/example.toml b/travis-test/example.toml index b366be3..1ad4a4d 100644 --- a/travis-test/example.toml +++ b/travis-test/example.toml @@ -244,4 +244,8 @@ color = "gray" [[fruit.variety]] name = "plantain" - \ No newline at end of file + + + +[user.contributed.cases] +slashes="SERVER\\MASTER"