PluginProbe
Patchstack – WordPress & Plugins Security / 2.3.1
Patchstack – WordPress & Plugins Security v2.3.1
2.3.7 trunk 2.1.0 2.1.1 2.1.10 2.1.11 2.1.12 2.1.13 2.1.14 2.1.15 2.1.16 2.1.17 2.1.18 2.1.19 2.1.2 2.1.20 2.1.21 2.1.22 2.1.23 2.1.24 2.1.25 2.1.3 2.1.4 2.1.5 2.1.6 All 49 releases
← All changes | includes/htaccess.php +2 -24 trunk2.3.1 View file →
@@ -120,9 +120,9 @@
120 120 }
121 121
122 122 // Get the current rules.
123 123 $current = $old = $fs->get_contents( ABSPATH . '.htaccess' );
124 - $current = $this->delete_all_between( '# Patchstack Firewall Start', '# Patchstack Firewall End', $current );
124 + $current = $this->delete_all_between( '# Patchstack Firewall Start', "# Patchstack Firewall End\r\n", $current );
125 125
126 126 // If no rules, then we delete the old ones.
127 127 if ( $rules != '' ) {
128 128 $current = "# Patchstack Firewall Start\r\n<IfModule mod_rewrite.c>\r\nRewriteEngine On\r\n" . $rules . "\r\n</IfModule>\r\n# Patchstack Firewall End\r\n" . $current;
@@ -159,22 +159,8 @@
159 159 if ( ! $fs->exists( ABSPATH . '.htaccess' ) ) {
160 160 $fs->touch( ABSPATH . '.htaccess' );
161 161 }
162 162
163 - // Some rule adjustments.
164 - $rewrites = [
165 - 'RedirectMatch 409 .(htaccess|htpasswd|errordocs|logs)$' => 'RedirectMatch 403 \.(htaccess|htpasswd|errordocs|logs)$',
166 - "\n RewriteCond %{HTTP_COOKIE} !^.*wordpress_logged_in.*$ [NC]" => '',
167 - "\n RewriteCond %{REMOTE_ADDR} !=18.221.197.243" => '',
168 - '^wp-includes/[^/]+.php$' => '^wp-includes/.*\.php$',
169 - 'RewriteRule ^debug*.*log$ index.php?webarx_fpage=502 [L,QSA]' => 'RewriteRule debug\.log$ index.php?webarx_fpage=502 [L,QSA]',
170 - '*.*' => '\.'
171 - ];
172 -
173 - foreach ($rewrites as $find => $replace) {
174 - $rules = str_replace($find, $replace, $rules);
175 - }
176 -
177 163 return $this->plugin->htaccess->self_check( $rules );
178 164 }
179 165
180 166 /**
@@ -345,16 +331,8 @@
345 331 if ( $begin_pos === false || $end_pos === false ) {
346 332 return $string;
347 333 }
348 334
349 - $end_pos += strlen( $end );
350 -
351 - // Consume any trailing newline characters so the block is removed cleanly
352 - // regardless of CRLF/LF line endings and repeated writes don't stack blank lines.
353 - while ( isset( $string[ $end_pos ] ) && ( $string[ $end_pos ] === "\r" || $string[ $end_pos ] === "\n" ) ) {
354 - $end_pos++;
355 - }
356 -
357 - $delete = substr( $string, $begin_pos, $end_pos - $begin_pos );
335 + $delete = substr( $string, $begin_pos, ( $end_pos + strlen( $end ) ) - $begin_pos );
358 336 return str_replace( $delete, '', $string );
359 337 }
360 338 }