A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/python/cpython/commit/439b9cfaf43080e91c4ad69f312f21fa098befc7 below:

Make urllib.parse.urlparse enforce that a scheme must begin… · python/cpython@439b9cf · GitHub

File tree Expand file treeCollapse file tree 3 files changed

+21

-1

lines changed

Filter options

Expand file treeCollapse file tree 3 files changed

+21

-1

lines changed Original file line number Diff line number Diff line change

@@ -668,6 +668,24 @@ def test_attributes_bad_port(self):

668 668

with self.assertRaises(ValueError):

669 669

p.port

670 670 671 +

def test_attributes_bad_scheme(self):

672 +

"""Check handling of invalid schemes."""

673 +

for bytes in (False, True):

674 +

for parse in (urllib.parse.urlsplit, urllib.parse.urlparse):

675 +

for scheme in (".", "+", "-", "0", "http&", "६http"):

676 +

with self.subTest(bytes=bytes, parse=parse, scheme=scheme):

677 +

url = scheme + "://www.example.net"

678 +

if bytes:

679 +

if url.isascii():

680 +

url = url.encode("ascii")

681 +

else:

682 +

continue

683 +

p = parse(url)

684 +

if bytes:

685 +

self.assertEqual(p.scheme, b"")

686 +

else:

687 +

self.assertEqual(p.scheme, "")

688 + 671 689

def test_attributes_without_netloc(self):

672 690

# This example is straight from RFC 3261. It looks like it

673 691

# should allow the username, hostname, and port to be filled

Original file line number Diff line number Diff line change

@@ -460,7 +460,7 @@ def urlsplit(url, scheme='', allow_fragments=True):

460 460

allow_fragments = bool(allow_fragments)

461 461

netloc = query = fragment = ''

462 462

i = url.find(':')

463 -

if i > 0:

463 +

if i > 0 and url[0].isascii() and url[0].isalpha():

464 464

for c in url[:i]:

465 465

if c not in scheme_chars:

466 466

break

Original file line number Diff line number Diff line change

@@ -0,0 +1,2 @@

1 +

Fix bug in :func:`urllib.parse.urlparse` that causes URL schemes that begin

2 +

with a digit, a plus sign, or a minus sign to be parsed incorrectly.

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4