File tree 2 files changed +20
-7
lines changed
2 files changed +20
-7
lines changed Original file line number Diff line number Diff line change @@ -556,12 +556,7 @@ def parse(self, s):
556
556
line = line .strip ()
557
557
558
558
if not line :
559
- # An empty line indicates the end of a ruleset.
560
- if current_ruleset and current_ruleset .is_not_empty ():
561
- self .__rulesets .append (current_ruleset )
562
-
563
- current_ruleset = None
564
- previous_line_was_a_user_agent = False
559
+ pass
565
560
else :
566
561
# Each non-empty line falls into one of six categories:
567
562
# 1) User-agent: blah blah blah
Original file line number Diff line number Diff line change @@ -77,7 +77,7 @@ def test_skip_malformed_line(self):
77
77
self .assertTrue (rp .is_allowed ('agent' , 'http://example.org/no/colon/in/this/line' ))
78
78
79
79
def test_utf8_bom (self ):
80
- """If there's a utf -8 BOM, we should parse it as such"""
80
+ """If there's a UTF -8 BOM, we should parse it as such"""
81
81
rp = robotstxtparser .RobotExclusionRulesParser ()
82
82
rp .parse (codecs .BOM_UTF8 + b'''
83
83
User-Agent: agent
@@ -163,3 +163,21 @@ def test_rfc_example(self):
163
163
self .assertFalse (rp .is_allowed ('anything' , 'http://example.org/%7Ejim/jim.html' ))
164
164
self .assertTrue (rp .is_allowed ('anything' , 'http://example.org/%7Emak/mak.html' ))
165
165
166
+ def test_support_grouping_blank_lines (self ):
167
+ """Make sure blank lines are ignored"""
168
+ rp = robotstxtparser .RobotExclusionRulesParser ()
169
+ rp .parse ('''
170
+ User-Agent: agent
171
+
172
+ Allow: /path
173
+
174
+ Disallow: /tmp
175
+
176
+ User-Agent: other
177
+
178
+ Disallow: /path
179
+ ''' )
180
+
181
+ self .assertTrue (rp .is_allowed ('agent' , 'http://example.org/path' ))
182
+ self .assertFalse (rp .is_allowed ('agent' , 'http://example.org/tmp' ))
183
+ self .assertFalse (rp .is_allowed ('other' , 'http://example.org/path' ))
You can’t perform that action at this time.
0 commit comments