-
Notifications
You must be signed in to change notification settings - Fork 278
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Update feedparser * Update markdown2
- Loading branch information
Showing
33 changed files
with
100 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# Copyright 2010-2022 Kurt McKee <[email protected]> | ||
# Copyright 2010-2023 Kurt McKee <[email protected]> | ||
# Copyright 2002-2008 Mark Pilgrim | ||
# All rights reserved. | ||
# | ||
|
@@ -32,7 +32,7 @@ | |
|
||
__author__ = 'Kurt McKee <[email protected]>' | ||
__license__ = 'BSD 2-clause' | ||
__version__ = '6.0.10' | ||
__version__ = '6.0.11' | ||
|
||
# HTTP "User-Agent" header to send to servers when downloading feeds. | ||
# If you are embedding feedparser in a larger application, you should | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# The public API for feedparser | ||
# Copyright 2010-2022 Kurt McKee <[email protected]> | ||
# Copyright 2010-2023 Kurt McKee <[email protected]> | ||
# Copyright 2002-2008 Mark Pilgrim | ||
# All rights reserved. | ||
# | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# Copyright 2010-2022 Kurt McKee <[email protected]> | ||
# Copyright 2010-2023 Kurt McKee <[email protected]> | ||
# Copyright 2002-2008 Mark Pilgrim | ||
# All rights reserved. | ||
# | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# Copyright 2010-2022 Kurt McKee <[email protected]> | ||
# Copyright 2010-2023 Kurt McKee <[email protected]> | ||
# Copyright 2002-2008 Mark Pilgrim | ||
# All rights reserved. | ||
# | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# Copyright 2010-2022 Kurt McKee <[email protected]> | ||
# Copyright 2010-2023 Kurt McKee <[email protected]> | ||
# Copyright 2002-2008 Mark Pilgrim | ||
# All rights reserved. | ||
# | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# Copyright 2010-2022 Kurt McKee <[email protected]> | ||
# Copyright 2010-2023 Kurt McKee <[email protected]> | ||
# Copyright 2002-2008 Mark Pilgrim | ||
# All rights reserved. | ||
# | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# Copyright 2010-2022 Kurt McKee <[email protected]> | ||
# Copyright 2010-2023 Kurt McKee <[email protected]> | ||
# Copyright 2002-2008 Mark Pilgrim | ||
# All rights reserved. | ||
# | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# Copyright 2010-2022 Kurt McKee <[email protected]> | ||
# Copyright 2010-2023 Kurt McKee <[email protected]> | ||
# Copyright 2002-2008 Mark Pilgrim | ||
# All rights reserved. | ||
# | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# Copyright 2010-2022 Kurt McKee <[email protected]> | ||
# Copyright 2010-2023 Kurt McKee <[email protected]> | ||
# Copyright 2002-2008 Mark Pilgrim | ||
# All rights reserved. | ||
# | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# Copyright 2010-2022 Kurt McKee <[email protected]> | ||
# Copyright 2010-2023 Kurt McKee <[email protected]> | ||
# Copyright 2002-2008 Mark Pilgrim | ||
# All rights reserved. | ||
# | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# Copyright 2010-2022 Kurt McKee <[email protected]> | ||
# Copyright 2010-2023 Kurt McKee <[email protected]> | ||
# Copyright 2002-2008 Mark Pilgrim | ||
# All rights reserved. | ||
# | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# Character encoding routines | ||
# Copyright 2010-2022 Kurt McKee <[email protected]> | ||
# Copyright 2010-2023 Kurt McKee <[email protected]> | ||
# Copyright 2002-2008 Mark Pilgrim | ||
# All rights reserved. | ||
# | ||
|
@@ -26,9 +26,9 @@ | |
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
# POSSIBILITY OF SUCH DAMAGE. | ||
|
||
import cgi | ||
import codecs | ||
import re | ||
import typing as t | ||
|
||
try: | ||
try: | ||
|
@@ -68,6 +68,30 @@ def lazy_chardet_encoding(data): | |
RE_XML_PI_ENCODING = re.compile(br'^<\?.*encoding=[\'"](.*?)[\'"].*\?>') | ||
|
||
|
||
def parse_content_type(line: str) -> t.Tuple[str, str]: | ||
"""Parse an HTTP Content-Type header. | ||
The return value will be a tuple of strings: | ||
the MIME type, and the value of the "charset" (if any). | ||
This is a custom replacement for Python's cgi.parse_header(). | ||
The cgi module will be removed in Python 3.13. | ||
""" | ||
|
||
chunks = line.split(";") | ||
if not chunks: | ||
return "", "" | ||
|
||
mime_type = chunks[0].strip() | ||
charset_value = "" | ||
for chunk in chunks[1:]: | ||
key, _, value = chunk.partition("=") | ||
if key.strip().lower() == "charset": | ||
charset_value = value.strip().strip("\"'") | ||
|
||
return mime_type, charset_value | ||
|
||
|
||
def convert_to_utf8(http_headers, data, result): | ||
"""Detect and convert the character encoding to UTF-8. | ||
|
@@ -181,10 +205,7 @@ def convert_to_utf8(http_headers, data, result): | |
# XML declaration encoding, and HTTP encoding, following the | ||
# heuristic defined in RFC 3023. | ||
http_content_type = http_headers.get('content-type') or '' | ||
http_content_type, params = cgi.parse_header(http_content_type) | ||
http_encoding = params.get('charset', '').replace("'", "") | ||
if isinstance(http_encoding, bytes): | ||
http_encoding = http_encoding.decode('utf-8', 'ignore') | ||
http_content_type, http_encoding = parse_content_type(http_content_type) | ||
|
||
acceptable_content_type = 0 | ||
application_content_types = ('application/xml', 'application/xml-dtd', | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# Exceptions used throughout feedparser | ||
# Copyright 2010-2022 Kurt McKee <[email protected]> | ||
# Copyright 2010-2023 Kurt McKee <[email protected]> | ||
# Copyright 2002-2008 Mark Pilgrim | ||
# All rights reserved. | ||
# | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# Copyright 2010-2022 Kurt McKee <[email protected]> | ||
# Copyright 2010-2023 Kurt McKee <[email protected]> | ||
# Copyright 2002-2008 Mark Pilgrim | ||
# All rights reserved. | ||
# | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# Copyright 2010-2022 Kurt McKee <[email protected]> | ||
# Copyright 2010-2023 Kurt McKee <[email protected]> | ||
# Copyright 2002-2008 Mark Pilgrim | ||
# All rights reserved. | ||
# | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# Copyright 2010-2022 Kurt McKee <[email protected]> | ||
# Copyright 2010-2023 Kurt McKee <[email protected]> | ||
# Copyright 2002-2008 Mark Pilgrim | ||
# All rights reserved. | ||
# | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# Support for the Atom, RSS, RDF, and CDF feed formats | ||
# Copyright 2010-2022 Kurt McKee <[email protected]> | ||
# Copyright 2010-2023 Kurt McKee <[email protected]> | ||
# Copyright 2002-2008 Mark Pilgrim | ||
# All rights reserved. | ||
# | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# Support for the administrative elements extension | ||
# Copyright 2010-2022 Kurt McKee <[email protected]> | ||
# Copyright 2010-2023 Kurt McKee <[email protected]> | ||
# Copyright 2002-2008 Mark Pilgrim | ||
# All rights reserved. | ||
# | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# Support for the Creative Commons licensing extensions | ||
# Copyright 2010-2022 Kurt McKee <[email protected]> | ||
# Copyright 2010-2023 Kurt McKee <[email protected]> | ||
# Copyright 2002-2008 Mark Pilgrim | ||
# All rights reserved. | ||
# | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# Support for the Dublin Core metadata extensions | ||
# Copyright 2010-2022 Kurt McKee <[email protected]> | ||
# Copyright 2010-2023 Kurt McKee <[email protected]> | ||
# Copyright 2002-2008 Mark Pilgrim | ||
# All rights reserved. | ||
# | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# Support for the GeoRSS format | ||
# Copyright 2010-2022 Kurt McKee <[email protected]> | ||
# Copyright 2010-2023 Kurt McKee <[email protected]> | ||
# Copyright 2002-2008 Mark Pilgrim | ||
# All rights reserved. | ||
# | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# Support for the iTunes format | ||
# Copyright 2010-2022 Kurt McKee <[email protected]> | ||
# Copyright 2010-2023 Kurt McKee <[email protected]> | ||
# Copyright 2002-2008 Mark Pilgrim | ||
# All rights reserved. | ||
# | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# Support for the Media RSS format | ||
# Copyright 2010-2022 Kurt McKee <[email protected]> | ||
# Copyright 2010-2023 Kurt McKee <[email protected]> | ||
# Copyright 2002-2008 Mark Pilgrim | ||
# All rights reserved. | ||
# | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# Support for the Podlove Simple Chapters format | ||
# Copyright 2010-2022 Kurt McKee <[email protected]> | ||
# Copyright 2010-2023 Kurt McKee <[email protected]> | ||
# Copyright 2002-2008 Mark Pilgrim | ||
# All rights reserved. | ||
# | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# The loose feed parser that interfaces with an SGML parsing library | ||
# Copyright 2010-2022 Kurt McKee <[email protected]> | ||
# Copyright 2010-2023 Kurt McKee <[email protected]> | ||
# Copyright 2002-2008 Mark Pilgrim | ||
# All rights reserved. | ||
# | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# The strict feed parser that interfaces with an XML parsing library | ||
# Copyright 2010-2022 Kurt McKee <[email protected]> | ||
# Copyright 2010-2023 Kurt McKee <[email protected]> | ||
# Copyright 2002-2008 Mark Pilgrim | ||
# All rights reserved. | ||
# | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# Copyright 2010-2022 Kurt McKee <[email protected]> | ||
# Copyright 2010-2023 Kurt McKee <[email protected]> | ||
# Copyright 2002-2008 Mark Pilgrim | ||
# All rights reserved. | ||
# | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# Copyright 2010-2022 Kurt McKee <[email protected]> | ||
# Copyright 2010-2023 Kurt McKee <[email protected]> | ||
# Copyright 2002-2008 Mark Pilgrim | ||
# All rights reserved. | ||
# | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# Copyright 2010-2022 Kurt McKee <[email protected]> | ||
# Copyright 2010-2023 Kurt McKee <[email protected]> | ||
# Copyright 2002-2008 Mark Pilgrim | ||
# All rights reserved. | ||
# | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# Copyright 2010-2022 Kurt McKee <[email protected]> | ||
# Copyright 2010-2023 Kurt McKee <[email protected]> | ||
# Copyright 2002-2008 Mark Pilgrim | ||
# All rights reserved. | ||
# | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.