From a281bee7d69f5347500e96e9df572e9ac5e7af15 Mon Sep 17 00:00:00 2001 From: Stefan Date: Fri, 2 Sep 2016 00:26:07 +0200 Subject: [PATCH] Improved XLSX Escaper performance for strings with only common/safe characters. --- src/Spout/Common/Escaper/XLSX.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Spout/Common/Escaper/XLSX.php b/src/Spout/Common/Escaper/XLSX.php index b5719a0..acd66bf 100644 --- a/src/Spout/Common/Escaper/XLSX.php +++ b/src/Spout/Common/Escaper/XLSX.php @@ -95,6 +95,10 @@ class XLSX implements EscaperInterface */ protected function escapeControlCharacters($string) { + if (1 !== preg_match('~[^A-Za-z0-9\-.:, ]~', $string)) { + return $string; + } + $escapedString = $this->escapeEscapeCharacter($string); return str_replace(array_values($this->controlCharactersEscapingMap), array_keys($this->controlCharactersEscapingMap), $escapedString); }