File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed
Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -171,4 +171,22 @@ public function testCaseSensitivePaths()
171171 $ this ->assertTrue ($ g ->isAllowed ('Googlebot ' , '/uppercase.html ' ));
172172 $ this ->assertFalse ($ g ->isAllowed ('Googlebot ' , '/UPPERCASE.HTML ' ));
173173 }
174+
175+ /**
176+ * Do not emit an E_NOTICE with an empty needle from strpos when a user-agent line is invalid (empty).
177+ * This effectively ignores the line.
178+ */
179+ public function testHandlesEmptyUserAgentLine ()
180+ {
181+ $ invalid_text = <<<EOF
182+ User-agent: foo
183+ User-agent:
184+ Disallow: /
185+ EOF ;
186+
187+ $ g = new RobotsTxt ($ invalid_text );
188+
189+ $ this ->assertFalse ($ g ->isAllowed ('foo ' , '/something ' ));
190+ $ this ->assertTrue ($ g ->isAllowed ('Googlebot ' , '/something ' ));
191+ }
174192}
You can’t perform that action at this time.
0 commit comments