| @@ -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; |
| @@ -345,16 +345,8 @@ | ||
| 345 | 345 | if ( $begin_pos === false || $end_pos === false ) { |
| 346 | 346 | return $string; |
| 347 | 347 | } |
| 348 | 348 | |
| 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 ); | |
| 349 | + $delete = substr( $string, $begin_pos, ( $end_pos + strlen( $end ) ) - $begin_pos ); | |
| 358 | 350 | return str_replace( $delete, '', $string ); |
| 359 | 351 | } |
| 360 | 352 | } |