Skip to content

Commit

Permalink
Merge pull request #50 from bopoda/master_issue48
Browse files Browse the repository at this point in the history
Directive with '+' not handled correctly, escape '+', resolve #48
  • Loading branch information
bopoda authored Apr 10, 2017
2 parents e6b0b21 + cef35b5 commit 763fd4a
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions RobotsTxtValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ private static function prepareRegexpRule($ruleValue)
'/\$./' => '\$',
'/\?/' => '\?',
'/\./' => '\.',
'/\+/' => '\+',
'/\*/' => '.*',
);

Expand Down
1 change: 1 addition & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<file>tests/t1gorTest.php</file>
<file>tests/MultipleUserAgentsRulesTest.php</file>
<file>tests/Issue13Test.php</file>
<file>tests/Issue48Test.php</file>
</testsuite>
</testsuites>
</phpunit>
26 changes: 26 additions & 0 deletions tests/Issue48Test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

<?php

class Issue48Test extends \PHPUnit\Framework\TestCase
{
/**
* Load library
*/
public static function setUpBeforeClass()
{
require_once(realpath(__DIR__.'/../RobotsTxtParser.php'));
require_once(realpath(__DIR__.'/../RobotsTxtValidator.php'));
}

public function testIsUrlAllowWithPlus()
{
$robotsTxtContentIssue = "
User-agent: *
Disallow: *telecommande++*
";
$robotsTxtParser = new RobotsTxtParser($robotsTxtContentIssue);
$robotsTxtValidator = new RobotsTxtValidator($robotsTxtParser->getRules());

$this->assertTrue($robotsTxtValidator->isUrlAllow('/telecommandes-box-decodeur.html'));
}
}

0 comments on commit 763fd4a

Please sign in to comment.