From 482eea4ffd2c9592ef351c72b7885471ddb66a4d Mon Sep 17 00:00:00 2001 From: Wilfried Date: Fri, 15 Nov 2019 14:20:24 +0100 Subject: [PATCH] fix: Escape pattern before use it in preg_replace If pattern contain special char (see PRCE), this can throw warning on preg_replace. --- lib/Simples/Document.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/Simples/Document.php b/lib/Simples/Document.php index 345447d..5c08829 100755 --- a/lib/Simples/Document.php +++ b/lib/Simples/Document.php @@ -144,7 +144,8 @@ protected function _export(array $data, array $options) { */ protected function _options($key, array & $options) { foreach($options['cast'] as $path => $_value) { - $_path = preg_replace('/^' . $key . '\./', '', $path) ; + $pattern = '/^' . preg_quote($key) . '\./'; + $_path = preg_replace($pattern, '', $path) ; if ($_path !== $path) { $options['cast'][$_path] = $_value ; unset($options['cast'][$path]) ;