Skip to content

Commit 34c3bb6

Browse files
committed
Fixed left square brackets incorrectly escaped
1 parent c5480c4 commit 34c3bb6

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

src/Escaper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class Escaper
1919
*/
2020
public $inLiteral = [
2121
'$' => '\\$', '(' => '\\(', ')' => '\\)', '*' => '\\*',
22-
'+' => '\\+', '.' => '\\.', '?' => '\\?', '[' => '\\]',
22+
'+' => '\\+', '.' => '\\.', '?' => '\\?', '[' => '\\[',
2323
'\\' => '\\\\', '^' => '\\^', '{' => '\\{', '|' => '\\|'
2424
];
2525

tests/BuilderTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,10 @@ public function getBuilderTests()
136136
['^', '_'],
137137
'[\\^_]'
138138
],
139+
[
140+
['[foo]', '[bar]'],
141+
'\\[(?:bar|foo)]'
142+
],
139143
];
140144
}
141145
}

tests/EscaperTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function getEscapeLiteralTests()
5858
['+', '\\+'],
5959
['.', '\\.'],
6060
['?', '\\?'],
61-
['[', '\\]'],
61+
['[', '\\['],
6262
['\\', '\\\\'],
6363
['^', '\\^'],
6464
['{', '\\{'],

0 commit comments

Comments
 (0)