From 5794920a3cbe71bdb88d11a14dff0046e0650b92 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 23 Jul 2023 23:45:51 +0200 Subject: [PATCH 01/44] Security/EscapeOutput: rename test case file ... to allow for adding additional test case files. --- ...nitTest.inc => EscapeOutputUnitTest.1.inc} | 0 .../Tests/Security/EscapeOutputUnitTest.php | 144 +++++++++--------- 2 files changed, 76 insertions(+), 68 deletions(-) rename WordPress/Tests/Security/{EscapeOutputUnitTest.inc => EscapeOutputUnitTest.1.inc} (100%) diff --git a/WordPress/Tests/Security/EscapeOutputUnitTest.inc b/WordPress/Tests/Security/EscapeOutputUnitTest.1.inc similarity index 100% rename from WordPress/Tests/Security/EscapeOutputUnitTest.inc rename to WordPress/Tests/Security/EscapeOutputUnitTest.1.inc diff --git a/WordPress/Tests/Security/EscapeOutputUnitTest.php b/WordPress/Tests/Security/EscapeOutputUnitTest.php index 4664245d45..8a65bff2c0 100644 --- a/WordPress/Tests/Security/EscapeOutputUnitTest.php +++ b/WordPress/Tests/Security/EscapeOutputUnitTest.php @@ -32,76 +32,84 @@ final class EscapeOutputUnitTest extends AbstractSniffUnitTest { /** * Returns the lines where errors should occur. * + * @param string $testFile The name of the file being tested. + * * @return array => */ - public function getErrorList() { - return array( - 17 => 1, - 19 => 1, - 36 => 1, - 39 => 1, - 40 => 1, - 41 => 1, - 43 => 1, - 46 => 1, - 53 => 1, - 59 => 1, - 60 => 1, - 65 => 1, - 68 => 1, - 71 => 1, - 73 => 1, - 75 => 1, - 101 => 1, - 103 => 1, - 111 => 1, - 112 => 1, - 113 => 1, - 114 => 1, - 125 => 1, - 126 => 1, // Old-style WPCS ignore comments are no longer supported. - 127 => 1, // Old-style WPCS ignore comments are no longer supported. - 128 => 1, // Old-style WPCS ignore comments are no longer supported. - 131 => 1, - 135 => 1, - 138 => 1, - 145 => 1, - 147 => 1, - 149 => 1, - 152 => 2, - 159 => 1, - 162 => 1, - 169 => 1, - 172 => 1, - 173 => 1, - 182 => 3, - 190 => 1, - 191 => 2, - 205 => 1, - 206 => 1, - 207 => 1, - 223 => 1, - 225 => 1, - 226 => 1, - 241 => 1, // Old-style WPCS ignore comments are no longer supported. - 245 => 1, // Old-style WPCS ignore comments are no longer supported. - 249 => 1, // Old-style WPCS ignore comments are no longer supported. - 252 => 1, - 253 => 1, - 263 => 1, - 264 => 1, - 266 => 1, - 282 => 1, - 286 => 1, - 289 => 1, - 294 => 1, - 297 => 1, - 307 => 1, - 313 => 1, - 314 => 1, - 315 => 1, - 319 => 1, - ); + public function getErrorList( $testFile = '' ) { + switch ( $testFile ) { + case 'EscapeOutputUnitTest.1.inc': + return array( + 17 => 1, + 19 => 1, + 36 => 1, + 39 => 1, + 40 => 1, + 41 => 1, + 43 => 1, + 46 => 1, + 53 => 1, + 59 => 1, + 60 => 1, + 65 => 1, + 68 => 1, + 71 => 1, + 73 => 1, + 75 => 1, + 101 => 1, + 103 => 1, + 111 => 1, + 112 => 1, + 113 => 1, + 114 => 1, + 125 => 1, + 126 => 1, // Old-style WPCS ignore comments are no longer supported. + 127 => 1, // Old-style WPCS ignore comments are no longer supported. + 128 => 1, // Old-style WPCS ignore comments are no longer supported. + 131 => 1, + 135 => 1, + 138 => 1, + 145 => 1, + 147 => 1, + 149 => 1, + 152 => 2, + 159 => 1, + 162 => 1, + 169 => 1, + 172 => 1, + 173 => 1, + 182 => 3, + 190 => 1, + 191 => 2, + 205 => 1, + 206 => 1, + 207 => 1, + 223 => 1, + 225 => 1, + 226 => 1, + 241 => 1, // Old-style WPCS ignore comments are no longer supported. + 245 => 1, // Old-style WPCS ignore comments are no longer supported. + 249 => 1, // Old-style WPCS ignore comments are no longer supported. + 252 => 1, + 253 => 1, + 263 => 1, + 264 => 1, + 266 => 1, + 282 => 1, + 286 => 1, + 289 => 1, + 294 => 1, + 297 => 1, + 307 => 1, + 313 => 1, + 314 => 1, + 315 => 1, + 319 => 1, + ); + + default: + return array(); + } } /** From 7d39aad0eeb5f909d43fec1ccb51e808ea158be1 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Thu, 27 Jul 2023 01:37:44 +0200 Subject: [PATCH 02/44] Security/EscapeOutput: move parse error related test to separate file ... to prevent it interfering with other tests. --- WordPress/Tests/Security/EscapeOutputUnitTest.1.inc | 2 +- WordPress/Tests/Security/EscapeOutputUnitTest.2.inc | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 WordPress/Tests/Security/EscapeOutputUnitTest.2.inc diff --git a/WordPress/Tests/Security/EscapeOutputUnitTest.1.inc b/WordPress/Tests/Security/EscapeOutputUnitTest.1.inc index b7a606bfc8..f9f1261667 100644 --- a/WordPress/Tests/Security/EscapeOutputUnitTest.1.inc +++ b/WordPress/Tests/Security/EscapeOutputUnitTest.1.inc @@ -181,7 +181,7 @@ echo '