Skip to content

Commit b61cef7

Browse files
committed
Fixed bug #867 : Squiz.Strings.DoubleQuoteUsage broken for some escape codes
1 parent 7271b28 commit b61cef7

File tree

5 files changed

+19
-4
lines changed

5 files changed

+19
-4
lines changed

CodeSniffer/Standards/Squiz/Sniffs/Strings/DoubleQuoteUsageSniff.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,22 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
103103

104104
$allowedChars = array(
105105
'\0',
106+
'\1',
107+
'\2',
108+
'\3',
109+
'\4',
110+
'\5',
111+
'\6',
112+
'\7',
106113
'\n',
107114
'\r',
108115
'\f',
109116
'\t',
110117
'\v',
111118
'\x',
112119
'\b',
120+
'\e',
121+
'\u',
113122
'\'',
114123
);
115124

CodeSniffer/Standards/Squiz/Tests/Strings/DoubleQuoteUsageUnitTest.inc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,7 @@ there";
2323
$string = 'Hello
2424
there';
2525

26+
$string = "\123 \234"."\u123"."\e";
27+
2628
echo "window.location = \"".$url."\";\n";
27-
echo ""
29+
echo ""

CodeSniffer/Standards/Squiz/Tests/Strings/DoubleQuoteUsageUnitTest.inc.fixed

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,7 @@ there';
2323
$string = 'Hello
2424
there';
2525

26+
$string = "\123 \234"."\u123"."\e";
27+
2628
echo 'window.location = "'.$url."\";\n";
27-
echo ''
29+
echo ''

CodeSniffer/Standards/Squiz/Tests/Strings/DoubleQuoteUsageUnitTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ public function getErrorList()
5252
18 => 1,
5353
19 => 1,
5454
21 => 1,
55-
26 => 1,
56-
27 => 1,
55+
28 => 1,
56+
29 => 1,
5757
);
5858

5959
}//end getErrorList()

package.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ http://pear.php.net/dtd/package-2.0.xsd">
6161
- Fixed bug #857 : PSR2.ControlStructure.SwitchDeclaration shouldn't check indent of curly brace closers
6262
- Fixed bug #859 : Switch statement indention issue when returning function call with closure
6363
- Fixed bug #861 : Single-line arrays and function calls can generate incorrect indentation errors
64+
- Fixed bug #867 : Squiz.Strings.DoubleQuoteUsage broken for some escape codes
65+
-- Thanks to Jack Blower for the help with the fix
6466
- Fixed bug #21005 : Incorrect indent detection when multiple properties are initialized to arrays
6567
- Fixed bug #21010 : Incorrect missing colon detection in CSS when first style is not on new line
6668
- Fixed bug #21011 : Incorrect error message text when newline found after opening brace

0 commit comments

Comments
 (0)