Skip to content

Commit 34117d2

Browse files
authored
Fix missing backslash escaping (#43)
1 parent f3d6bbe commit 34117d2

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

src/Builder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ class Builder extends TestMethodProvider
122122
'allowed' => self::METHOD_TYPES_ALLOWED_FOR_CHARACTERS
123123
],
124124
'backslash' => [
125-
'add' => '\\',
125+
'add' => '\\\\',
126126
'type' => self::METHOD_TYPE_CHARACTER,
127127
'allowed' => self::METHOD_TYPES_ALLOWED_FOR_CHARACTERS
128128
],

src/Language/Helpers/Matcher.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ class Matcher
3030
'all' => ['class' => Methods\SimpleMethod::class, 'method' => 'all'],
3131
'anything' => ['class' => Methods\SimpleMethod::class, 'method' => 'any'],
3232
'tab' => ['class' => Methods\SimpleMethod::class, 'method' => 'tab'],
33+
'backslash' => ['class' => Methods\SimpleMethod::class, 'method' => 'backslash'],
3334
'unicode' => ['class' => Methods\SimpleMethod::class, 'method' => 'unicode'],
3435
'digit' => ['class' => Methods\SimpleMethod::class, 'method' => 'digit'],
3536
'not digit' => ['class' => Methods\SimpleMethod::class, 'method' => 'notDigit'],

tests/LanguageInterpreterTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ public function testParser()
5353

5454
$srl = new SRL('starts with not one of "!@#/"');
5555
$this->assertEquals('/^[^!@#\/]/', $srl->get());
56+
57+
$srl = new SRL('backslash');
58+
$this->assertEquals('/\\\\/', $srl->get());
59+
$this->assertTrue($srl->isMatching('\\'));
60+
$this->assertFalse($srl->isMatching('/'));
5661
}
5762

5863
public function testEmail()

0 commit comments

Comments
 (0)