Skip to content

Commit

Permalink
Merge pull request #82 from python-hyper/bug/81
Browse files Browse the repository at this point in the history
Fix URI resolution with scheme-only URI
  • Loading branch information
sigmavirus24 committed Jan 9, 2022
2 parents b2efb2d + f279dd3 commit 2d0317b
Show file tree
Hide file tree
Showing 39 changed files with 345 additions and 284 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/main.yml
@@ -0,0 +1,48 @@
name: main

on:
push:
branches: [master, main]
tags:
pull_request:

jobs:
main:
strategy:
matrix:
include:
# linux
- os: ubuntu-latest
python: pypy-3.7
toxenv: py
- os: ubuntu-latest
python: 3.7
toxenv: py
- os: ubuntu-latest
python: 3.8
toxenv: py
- os: ubuntu-latest
python: 3.9
toxenv: py
- os: ubuntu-latest
python: '3.10'
toxenv: py
# windows
- os: windows-latest
python: 3.7
toxenv: py
# misc
- os: ubuntu-latest
python: 3.9
toxenv: docs
- os: ubuntu-latest
python: 3.9
toxenv: pre-commit
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python }}
- run: python -mpip install --upgrade setuptools pip tox virtualenv
- run: tox -e ${{ matrix.toxenv }}
3 changes: 3 additions & 0 deletions .gitignore
Expand Up @@ -2,6 +2,9 @@
.coverage
.tox
*.egg-info
.pytest_cache
.cache/
build/
doc/_build/
dist/
t.py
36 changes: 36 additions & 0 deletions .pre-commit-config.yaml
@@ -0,0 +1,36 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.1.0
hooks:
- id: check-yaml
- id: debug-statements
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/asottile/reorder_python_imports
rev: v2.6.0
hooks:
- id: reorder-python-imports
args: [--application-directories, '.:src', --py37-plus]
- repo: https://github.com/psf/black
rev: 21.12b0
hooks:
- id: black
args: [--line-length=79]
- repo: https://github.com/asottile/pyupgrade
rev: v2.31.0
hooks:
- id: pyupgrade
args: [--py37-plus]
- repo: https://github.com/pycqa/flake8
rev: 4.0.1
hooks:
- id: flake8
exclude: ^(tests/|docs/|setup.py)
additional_dependencies:
- flake8-docstrings
- flake8-import-order
#- repo: https://github.com/pre-commit/mirrors-mypy
# rev: v0.910-1
# hooks:
# - id: mypy
# exclude: ^(docs/|example-plugin/)
2 changes: 1 addition & 1 deletion README.rst
@@ -1,7 +1,7 @@
rfc3986
=======

A Python implementation of `RFC 3986`_ including validation and authority
A Python implementation of `RFC 3986`_ including validation and authority
parsing.

Installation
Expand Down
2 changes: 1 addition & 1 deletion docs/source/api-ref/miscellaneous.rst
Expand Up @@ -2,7 +2,7 @@
Miscellaneous Submodules
==========================

There are several submodules in |rfc3986| that are not meant to be exposed to
There are several submodules in |rfc3986| that are not meant to be exposed to
users directly but which are valuable to document, regardless.

.. data:: rfc3986.misc.UseExisting
Expand Down
63 changes: 33 additions & 30 deletions docs/source/conf.py
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
#
# rfc3986 documentation build configuration file, created by
# sphinx-quickstart on Tue Mar 14 07:06:46 2017.
Expand All @@ -11,7 +10,6 @@
#
# All configuration values have a default; values that are commented out
# serve to show the default.

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
Expand All @@ -35,29 +33,29 @@
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.doctest',
'sphinx.ext.intersphinx',
'sphinx.ext.coverage',
'sphinx-prompt',
"sphinx.ext.autodoc",
"sphinx.ext.doctest",
"sphinx.ext.intersphinx",
"sphinx.ext.coverage",
"sphinx-prompt",
]

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
templates_path = ["_templates"]

# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
#
# source_suffix = ['.rst', '.md']
source_suffix = '.rst'
source_suffix = ".rst"

# The master toctree document.
master_doc = 'index'
master_doc = "index"

# General information about the project.
project = u'rfc3986'
copyright = u'2017, Ian Stapleton Cordasco'
author = u'Ian Stapleton Cordasco'
project = "rfc3986"
copyright = "2017, Ian Stapleton Cordasco"
author = "Ian Stapleton Cordasco"

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
Expand All @@ -81,7 +79,7 @@
exclude_patterns = []

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
pygments_style = "sphinx"

# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = False
Expand All @@ -92,7 +90,7 @@
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'sphinx_rtd_theme'
html_theme = "sphinx_rtd_theme"

# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
Expand All @@ -103,13 +101,13 @@
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
html_static_path = ["_static"]


# -- Options for HTMLHelp output ------------------------------------------

# Output file base name for HTML help builder.
htmlhelp_basename = 'rfc3986doc'
htmlhelp_basename = "rfc3986doc"


# -- Options for LaTeX output ---------------------------------------------
Expand All @@ -118,15 +116,12 @@
# The paper size ('letterpaper' or 'a4paper').
#
# 'papersize': 'letterpaper',

# The font size ('10pt', '11pt' or '12pt').
#
# 'pointsize': '10pt',

# Additional stuff for the LaTeX preamble.
#
# 'preamble': '',

# Latex figure (float) alignment
#
# 'figure_align': 'htbp',
Expand All @@ -136,19 +131,21 @@
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'rfc3986.tex', u'rfc3986 Documentation',
u'Ian Stapleton Cordasco', 'manual'),
(
master_doc,
"rfc3986.tex",
"rfc3986 Documentation",
"Ian Stapleton Cordasco",
"manual",
),
]


# -- Options for manual page output ---------------------------------------

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'rfc3986', u'rfc3986 Documentation',
[author], 1)
]
man_pages = [(master_doc, "rfc3986", "rfc3986 Documentation", [author], 1)]


# -- Options for Texinfo output -------------------------------------------
Expand All @@ -157,11 +154,17 @@
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'rfc3986', u'rfc3986 Documentation',
author, 'rfc3986', 'One line description of project.',
'Miscellaneous'),
(
master_doc,
"rfc3986",
"rfc3986 Documentation",
author,
"rfc3986",
"One line description of project.",
"Miscellaneous",
),
]


# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {'https://docs.python.org/': None}
intersphinx_mapping = {"https://docs.python.org/": None}
4 changes: 2 additions & 2 deletions docs/source/index.rst
Expand Up @@ -2,11 +2,11 @@
rfc3986
=========

|rfc3986| is a Python implementation of :rfc:`3986` including validation and
|rfc3986| is a Python implementation of :rfc:`3986` including validation and
authority parsing. This module also supports :rfc:`6874` which adds support
for zone identifiers to IPv6 Addresses.

The maintainers strongly suggest using `pip`_ to install |rfc3986|. For
The maintainers strongly suggest using `pip`_ to install |rfc3986|. For
example,

.. prompt:: bash
Expand Down
1 change: 0 additions & 1 deletion docs/source/release-notes/0.2.2.rst
Expand Up @@ -4,4 +4,3 @@
- Update the regular name regular expression to accept all of the characters
allowed in the RFC. Closes bug #11 (Thanks Viktor Haag). Previously URIs
similar to "http://http-bin.org" would be considered invalid.

2 changes: 1 addition & 1 deletion docs/source/release-notes/1.1.0.rst
@@ -1,7 +1,7 @@
1.1.0 -- 2017-07-18
-------------------

- Correct the regular expression for the User Information sub-component of the
- Correct the regular expression for the User Information sub-component of the
Authority Component.

See also `GitHub #26`_
Expand Down
2 changes: 1 addition & 1 deletion docs/source/release-notes/1.4.0.rst
Expand Up @@ -7,7 +7,7 @@ Security
- Prevent users from receiving an invalid authority parsed from a malicious
URL. Previously we did not stop parsing the authority section at the first
backslash (``\\``) character. As a result, it was possible to trick our
parser into parsing up to the first forward-slash (``/``) and thus
parser into parsing up to the first forward-slash (``/``) and thus
generating an invalid authority.

See also `GitHub pr-64`_ and `the blog post that sparked this change`_
Expand Down
11 changes: 10 additions & 1 deletion docs/source/release-notes/unreleased.rst
@@ -1,4 +1,13 @@
1.x.y - 202z-aa-bb
2.0.0 - 202z-aa-bb
------------------

- Drop support for Python 2.7, 3.3, 3.4, 3.5, 3.6

- Add support for Python 3.8, 3.9, 3.10

- Fix bug in resolving URIs that only contain schemes which are valid per the
RFC - `bug 81`_

.. links below here
.. _bug 81:
https://github.com/python-hyper/rfc3986/issues/81
4 changes: 2 additions & 2 deletions docs/source/user/validating.rst
Expand Up @@ -143,9 +143,9 @@ Checking the Validity of Components
-----------------------------------

As of version 1.1.0, |rfc3986| allows users to check the validity of a URI
Reference using a :class:`~rfc3986.validators.Validator`. Along with the above
Reference using a :class:`~rfc3986.validators.Validator`. Along with the above
examples we can also check that a URI is valid per :rfc:`3986`. The validation
of the components is pre-determined so all we need to do is specify which
of the components is pre-determined so all we need to do is specify which
components we want to validate:

>>> from rfc3986 import validators, uri_reference
Expand Down
35 changes: 35 additions & 0 deletions setup.cfg
@@ -1,2 +1,37 @@
[metadata]
name = rfc3986
version = attr: rfc3986.__version__
description = Validating URI References per RFC 3986
long_description = file: README.rst
author = Ian Stapleton Cordasco
author_email = graffatcolmingov@gmail.com
url = http://rfc3986.readthedocs.io
license = Apache 2.0
classifiers =
Development Status :: 5 - Production/Stable
Intended Audience :: Developers
Natural Language :: English
License :: OSI Approved :: Apache Software License
Programming Language :: Python
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10

[options]
packages = find:
package_dir = =src
include_package_data = True

[options.packages.find]
where = src

[options.extras_require]
idna2008 = idna

[options.package_data]
* =
LICENSE

[bdist_wheel]
universal = 1

0 comments on commit 2d0317b

Please sign in to comment.