Skip to content

Commit d08830a

Browse files
committed
Remove attempt at validating feeds in error pages
Also document 403 and web app firewalls for #143
1 parent bb9845c commit d08830a

File tree

2 files changed

+7
-17
lines changed

2 files changed

+7
-17
lines changed

docs/error/HttpError.html

+4-1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ <h2>Explanation</h2>
3030
<p>This usually means that the URL was wrong, or that permissions on
3131
the server don't allow us to fetch that file. The error shows the
3232
message that the server sent, which may help.</p>
33+
34+
<p>If the error is "403 Forbidden" and your Web site uses a Web App Firewall, you may need to allow-list the feedvalidator User-Agent: "FeedValidator/1.3".
35+
3336
</div>
3437
<h2>Solution</h2>
3538
<div class="docbody">
@@ -57,4 +60,4 @@ <h2>Not clear? Disagree?</h2>
5760

5861

5962

60-
</body></html>
63+
</body></html>

src/feedvalidator/__init__.py

+3-16
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,7 @@ def validateURL(url, firstOccurrenceOnly=1, wantRawData=0, groupEvents=0):
215215
usock = urllib.request.urlopen(request, context=ctx1)
216216
elif isinstance(x.reason, ssl.SSLCertVerificationError) and "CERTIFICATE_VERIFY_FAILED" in x.reason.reason:
217217
raise ValidationFailure(logging.HttpsProtocolError({'message': "HTTPs server has incorrect certificate configuration"}))
218-
else:
219-
raise x
218+
raise
220219
rawdata = usock.read(MAXDATALENGTH)
221220
if usock.read(1):
222221
raise ValidationFailure(logging.ValidatorLimit({'limit': 'feed length > ' + str(MAXDATALENGTH) + ' bytes'}))
@@ -238,22 +237,10 @@ def validateURL(url, firstOccurrenceOnly=1, wantRawData=0, groupEvents=0):
238237
except BadStatusLine as status:
239238
raise ValidationFailure(logging.HttpError({'status': status.__class__}))
240239
except ValidationFailure as x:
241-
raise x
240+
raise
242241

243242
except urllib.error.HTTPError as status:
244-
rawdata = status.read()
245-
if len(rawdata) < 512 or 'content-encoding' in status.headers:
246-
loggedEvents.append(logging.HttpError({'status': status}))
247-
usock = status
248-
else:
249-
rawdata = re.sub(b'<!--.*?-->','',rawdata)
250-
lastline = rawdata.strip().split(b'\n')[-1].strip()
251-
if sniffPossibleFeed(rawdata.decode('utf-8')):
252-
loggedEvents.append(logging.HttpError({'status': status}))
253-
loggedEvents.append(logging.HttpErrorWithPossibleFeed({}))
254-
usock = status
255-
else:
256-
raise ValidationFailure(logging.HttpError({'status': status}))
243+
raise ValidationFailure(logging.HttpError({'status': status}))
257244
except urllib.error.URLError as x:
258245
raise ValidationFailure(logging.HttpError({'status': x.reason}))
259246
except Timeout as x:

0 commit comments

Comments
 (0)