szepeviktor / multipart-robotstxt-editor

Customize your WordPress site's robots.txt and include remote content to it.
https://wordpress.org/plugins/multipart-robotstxt-editor/
2 stars 3 forks source link

`RobotsTxtParser` does not work on Windows server #5

Closed joostdekeijzer closed 6 years ago

joostdekeijzer commented 6 years ago

The parser uses PHP_EOL als a line delimiter, which on Windows is "\r\n" (two characters!).

The newLine() method tests for a newline on either the current char (one character so the "\r" on Windows) or on the current word. Since the current word contains all text before the newline (eg. "*\r\n") it is never triggered, resulting in an empty rules array.

This change forces the use of "\n" as a newline character in stead of PHP_EOL.

szepeviktor commented 6 years ago

Hello! You are right.

Do you expect me to release it on WP.org?

szepeviktor commented 6 years ago

@joostdekeijzer Actually we have more of those EOL-s. https://github.com/szepeviktor/multipart-robotstxt-editor/blob/master/mp-robotstxt.php#L284-L308

joostdekeijzer commented 6 years ago

Ah, yes. I think the other EOL-s are not breaking...

The preg \R placeholder is really nice in this context (eg. preg_replace( '/\R/', "\n", $content)). It represents all newline possiblities. See http://php.net/manual/en/regexp.reference.escape.php.

My site is currently fixed, so no urgent need to release on WP.org, thanks!

szepeviktor commented 6 years ago

OK, I've moved to static robots.txt-s.