Skip to content

Commit

Permalink
Merge pull request #417 from kurtmckee/hotfix-6.0.11
Browse files Browse the repository at this point in the history
Hotfix 6.0.11
  • Loading branch information
kurtmckee committed Dec 10, 2023
2 parents 32adbe1 + 7da33c6 commit 6cdc208
Show file tree
Hide file tree
Showing 40 changed files with 86 additions and 51 deletions.
4 changes: 2 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ feedparser and its unit tests are released under the following license:

----- begin license block -----

Copyright (C) 2010-2022 Kurt McKee <contactme@kurtmckee.org>
Copyright (C) 2010-2023 Kurt McKee <contactme@kurtmckee.org>
Copyright (C) 2002-2008 Mark Pilgrim
All rights reserved.

Expand Down Expand Up @@ -38,7 +38,7 @@ released under the following license:

----- begin license block -----

Copyright (C) 2010-2022 Kurt McKee <contactme@kurtmckee.org>
Copyright (C) 2010-2023 Kurt McKee <contactme@kurtmckee.org>
Copyright (C) 2004-2008 Mark Pilgrim. All rights reserved.

Redistribution and use in source (Sphinx ReST) and "compiled" forms (HTML, PDF,
Expand Down
3 changes: 3 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
coming in the next release:

6.0.11 - 9 December 2023
* Resolve ``cgi`` module deprecation warnings. (#330)

6.0.10 - 21 May 2022
* Populate ``<summary>`` correctly if it comes after ``<content>``. (#260)

Expand Down
21 changes: 14 additions & 7 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
feedparser - Parse Atom and RSS feeds in Python.
..
This file is part of feedparser.
Copyright 2010-2023 Kurt McKee <contactme@kurtmckee.org>
Copyright 2002-2008 Mark Pilgrim
Released under the BSD 2-clause license.
| Copyright 2010-2022 Kurt McKee <contactme@kurtmckee.org>
| Copyright 2002-2008 Mark Pilgrim

feedparser is open source. See the LICENSE file for more information.
feedparser
##########

Parse Atom and RSS feeds in Python.

----


Installation
============

feedparser can be installed by running pip:

.. code-block:: shell
.. code-block:: console
$ pip install feedparser
Expand All @@ -30,7 +37,7 @@ To build the documentation you'll need the Sphinx package, which is available at

You can then build HTML pages using a command similar to:

.. code-block:: shell
.. code-block:: console
$ sphinx-build -b html docs/ fpdocs
Expand All @@ -42,7 +49,7 @@ Testing

Feedparser has an extensive test suite, powered by tox. To run it, type this:

.. code-block:: shell
.. code-block:: console
$ python -m venv venv
$ source venv/bin/activate # or "venv\bin\activate.ps1" on Windows
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Fixed
-----

* Replace a call to ``cgi.parse_header()``, which causes deprecation warnings in Python 3.11.
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

# project information
project = 'feedparser'
copyright = '2010-2022 Kurt McKee, 2004-2008 Mark Pilgrim'
copyright = '2010-2023 Kurt McKee, 2004-2008 Mark Pilgrim'
language = 'en'

# documentation options
Expand Down
2 changes: 1 addition & 1 deletion docs/license.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Documentation license
=====================

Copyright 2010-2022 Kurt McKee, 2004-2008 Mark Pilgrim. All rights reserved.
Copyright 2010-2023 Kurt McKee, 2004-2008 Mark Pilgrim. All rights reserved.

Redistribution and use in source (Sphinx ReST) and "compiled" forms (HTML, PDF,
PostScript, RTF and so forth) with or without modification, are permitted
Expand Down
2 changes: 1 addition & 1 deletion dodo.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# This file is part of feedparser.
# Copyright 2020-2022 Kurt McKee <contactme@kurtmckee.org>
# Copyright 2020-2023 Kurt McKee <contactme@kurtmckee.org>
# Released under the BSD 2-clause license.

# The tasks defined in this file automates the entire
Expand Down
4 changes: 2 additions & 2 deletions feedparser/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2010-2022 Kurt McKee <contactme@kurtmckee.org>
# Copyright 2010-2023 Kurt McKee <contactme@kurtmckee.org>
# Copyright 2002-2008 Mark Pilgrim
# All rights reserved.
#
Expand Down Expand Up @@ -32,7 +32,7 @@

__author__ = 'Kurt McKee <contactme@kurtmckee.org>'
__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
Expand Down
2 changes: 1 addition & 1 deletion feedparser/api.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# The public API for feedparser
# Copyright 2010-2022 Kurt McKee <contactme@kurtmckee.org>
# Copyright 2010-2023 Kurt McKee <contactme@kurtmckee.org>
# Copyright 2002-2008 Mark Pilgrim
# All rights reserved.
#
Expand Down
2 changes: 1 addition & 1 deletion feedparser/datetimes/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2010-2022 Kurt McKee <contactme@kurtmckee.org>
# Copyright 2010-2023 Kurt McKee <contactme@kurtmckee.org>
# Copyright 2002-2008 Mark Pilgrim
# All rights reserved.
#
Expand Down
2 changes: 1 addition & 1 deletion feedparser/datetimes/asctime.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2010-2022 Kurt McKee <contactme@kurtmckee.org>
# Copyright 2010-2023 Kurt McKee <contactme@kurtmckee.org>
# Copyright 2002-2008 Mark Pilgrim
# All rights reserved.
#
Expand Down
2 changes: 1 addition & 1 deletion feedparser/datetimes/greek.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2010-2022 Kurt McKee <contactme@kurtmckee.org>
# Copyright 2010-2023 Kurt McKee <contactme@kurtmckee.org>
# Copyright 2002-2008 Mark Pilgrim
# All rights reserved.
#
Expand Down
2 changes: 1 addition & 1 deletion feedparser/datetimes/hungarian.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2010-2022 Kurt McKee <contactme@kurtmckee.org>
# Copyright 2010-2023 Kurt McKee <contactme@kurtmckee.org>
# Copyright 2002-2008 Mark Pilgrim
# All rights reserved.
#
Expand Down
2 changes: 1 addition & 1 deletion feedparser/datetimes/iso8601.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2010-2022 Kurt McKee <contactme@kurtmckee.org>
# Copyright 2010-2023 Kurt McKee <contactme@kurtmckee.org>
# Copyright 2002-2008 Mark Pilgrim
# All rights reserved.
#
Expand Down
2 changes: 1 addition & 1 deletion feedparser/datetimes/korean.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2010-2022 Kurt McKee <contactme@kurtmckee.org>
# Copyright 2010-2023 Kurt McKee <contactme@kurtmckee.org>
# Copyright 2002-2008 Mark Pilgrim
# All rights reserved.
#
Expand Down
2 changes: 1 addition & 1 deletion feedparser/datetimes/perforce.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2010-2022 Kurt McKee <contactme@kurtmckee.org>
# Copyright 2010-2023 Kurt McKee <contactme@kurtmckee.org>
# Copyright 2002-2008 Mark Pilgrim
# All rights reserved.
#
Expand Down
2 changes: 1 addition & 1 deletion feedparser/datetimes/rfc822.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2010-2022 Kurt McKee <contactme@kurtmckee.org>
# Copyright 2010-2023 Kurt McKee <contactme@kurtmckee.org>
# Copyright 2002-2008 Mark Pilgrim
# All rights reserved.
#
Expand Down
2 changes: 1 addition & 1 deletion feedparser/datetimes/w3dtf.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2010-2022 Kurt McKee <contactme@kurtmckee.org>
# Copyright 2010-2023 Kurt McKee <contactme@kurtmckee.org>
# Copyright 2002-2008 Mark Pilgrim
# All rights reserved.
#
Expand Down
33 changes: 27 additions & 6 deletions feedparser/encodings.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Character encoding routines
# Copyright 2010-2022 Kurt McKee <contactme@kurtmckee.org>
# Copyright 2010-2023 Kurt McKee <contactme@kurtmckee.org>
# Copyright 2002-2008 Mark Pilgrim
# All rights reserved.
#
Expand All @@ -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:
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion feedparser/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Exceptions used throughout feedparser
# Copyright 2010-2022 Kurt McKee <contactme@kurtmckee.org>
# Copyright 2010-2023 Kurt McKee <contactme@kurtmckee.org>
# Copyright 2002-2008 Mark Pilgrim
# All rights reserved.
#
Expand Down
2 changes: 1 addition & 1 deletion feedparser/html.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2010-2022 Kurt McKee <contactme@kurtmckee.org>
# Copyright 2010-2023 Kurt McKee <contactme@kurtmckee.org>
# Copyright 2002-2008 Mark Pilgrim
# All rights reserved.
#
Expand Down
2 changes: 1 addition & 1 deletion feedparser/http.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2010-2022 Kurt McKee <contactme@kurtmckee.org>
# Copyright 2010-2023 Kurt McKee <contactme@kurtmckee.org>
# Copyright 2002-2008 Mark Pilgrim
# All rights reserved.
#
Expand Down
2 changes: 1 addition & 1 deletion feedparser/mixin.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2010-2022 Kurt McKee <contactme@kurtmckee.org>
# Copyright 2010-2023 Kurt McKee <contactme@kurtmckee.org>
# Copyright 2002-2008 Mark Pilgrim
# All rights reserved.
#
Expand Down
2 changes: 1 addition & 1 deletion feedparser/namespaces/_base.py
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 <contactme@kurtmckee.org>
# Copyright 2010-2023 Kurt McKee <contactme@kurtmckee.org>
# Copyright 2002-2008 Mark Pilgrim
# All rights reserved.
#
Expand Down
2 changes: 1 addition & 1 deletion feedparser/namespaces/admin.py
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 <contactme@kurtmckee.org>
# Copyright 2010-2023 Kurt McKee <contactme@kurtmckee.org>
# Copyright 2002-2008 Mark Pilgrim
# All rights reserved.
#
Expand Down
2 changes: 1 addition & 1 deletion feedparser/namespaces/cc.py
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 <contactme@kurtmckee.org>
# Copyright 2010-2023 Kurt McKee <contactme@kurtmckee.org>
# Copyright 2002-2008 Mark Pilgrim
# All rights reserved.
#
Expand Down
2 changes: 1 addition & 1 deletion feedparser/namespaces/dc.py
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 <contactme@kurtmckee.org>
# Copyright 2010-2023 Kurt McKee <contactme@kurtmckee.org>
# Copyright 2002-2008 Mark Pilgrim
# All rights reserved.
#
Expand Down
2 changes: 1 addition & 1 deletion feedparser/namespaces/georss.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Support for the GeoRSS format
# Copyright 2010-2022 Kurt McKee <contactme@kurtmckee.org>
# Copyright 2010-2023 Kurt McKee <contactme@kurtmckee.org>
# Copyright 2002-2008 Mark Pilgrim
# All rights reserved.
#
Expand Down
2 changes: 1 addition & 1 deletion feedparser/namespaces/itunes.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Support for the iTunes format
# Copyright 2010-2022 Kurt McKee <contactme@kurtmckee.org>
# Copyright 2010-2023 Kurt McKee <contactme@kurtmckee.org>
# Copyright 2002-2008 Mark Pilgrim
# All rights reserved.
#
Expand Down
2 changes: 1 addition & 1 deletion feedparser/namespaces/mediarss.py
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 <contactme@kurtmckee.org>
# Copyright 2010-2023 Kurt McKee <contactme@kurtmckee.org>
# Copyright 2002-2008 Mark Pilgrim
# All rights reserved.
#
Expand Down
2 changes: 1 addition & 1 deletion feedparser/namespaces/psc.py
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 <contactme@kurtmckee.org>
# Copyright 2010-2023 Kurt McKee <contactme@kurtmckee.org>
# Copyright 2002-2008 Mark Pilgrim
# All rights reserved.
#
Expand Down
2 changes: 1 addition & 1 deletion feedparser/parsers/loose.py
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 <contactme@kurtmckee.org>
# Copyright 2010-2023 Kurt McKee <contactme@kurtmckee.org>
# Copyright 2002-2008 Mark Pilgrim
# All rights reserved.
#
Expand Down
2 changes: 1 addition & 1 deletion feedparser/parsers/strict.py
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 <contactme@kurtmckee.org>
# Copyright 2010-2023 Kurt McKee <contactme@kurtmckee.org>
# Copyright 2002-2008 Mark Pilgrim
# All rights reserved.
#
Expand Down
2 changes: 1 addition & 1 deletion feedparser/sanitizer.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2010-2022 Kurt McKee <contactme@kurtmckee.org>
# Copyright 2010-2023 Kurt McKee <contactme@kurtmckee.org>
# Copyright 2002-2008 Mark Pilgrim
# All rights reserved.
#
Expand Down
2 changes: 1 addition & 1 deletion feedparser/sgml.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2010-2022 Kurt McKee <contactme@kurtmckee.org>
# Copyright 2010-2023 Kurt McKee <contactme@kurtmckee.org>
# Copyright 2002-2008 Mark Pilgrim
# All rights reserved.
#
Expand Down
2 changes: 1 addition & 1 deletion feedparser/urls.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2010-2022 Kurt McKee <contactme@kurtmckee.org>
# Copyright 2010-2023 Kurt McKee <contactme@kurtmckee.org>
# Copyright 2002-2008 Mark Pilgrim
# All rights reserved.
#
Expand Down
2 changes: 1 addition & 1 deletion feedparser/util.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2010-2022 Kurt McKee <contactme@kurtmckee.org>
# Copyright 2010-2023 Kurt McKee <contactme@kurtmckee.org>
# Copyright 2002-2008 Mark Pilgrim
# All rights reserved.
#
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2010-2022 Kurt McKee <contactme@kurtmckee.org>
# Copyright 2010-2023 Kurt McKee <contactme@kurtmckee.org>
# Copyright 2002-2008 Mark Pilgrim
# All rights reserved.
#
Expand Down
2 changes: 1 addition & 1 deletion tests/runtests.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2010-2020 Kurt McKee <contactme@kurtmckee.org>
# Copyright 2010-2023 Kurt McKee <contactme@kurtmckee.org>
# Copyright 2004-2008 Mark Pilgrim
# All rights reserved.
#
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# and then run "tox" from this directory.

[tox]
envlist = py{36, 37, 38, 39}-{chardet, }
envlist = py{36, 37, 38, 39}{-chardet, }
skip_missing_interpreters = True

[testenv]
Expand Down

0 comments on commit 6cdc208

Please sign in to comment.