Skip to content

Commit 5047553

Browse files
fix: use quote instead of quote_plus
MDQ spec explicitly asks for spaces to be encoded as %20, not + This is achieved by urllib.parse.quote - the only difference quote_plus brings is it would be encoding spaces as '+': https://docs.python.org/3/library/urllib.parse.html#urllib.parse.quote_plus While entityIDs cannot really contain spaces (not permitted in an URI), this is all just a technicality, but quote is the correct function to use.
1 parent 8b9bf69 commit 5047553

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

src/pyff/api.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from datetime import datetime, timedelta
55
from json import dumps
66
from typing import Any, Optional
7-
from urllib.parse import quote_plus
7+
from urllib.parse import quote
88

99
import pyramid.httpexceptions as exc
1010
import pytz
@@ -394,7 +394,7 @@ def _links(url: str, title: Any = None) -> None:
394394
aliases = request.registry.aliases
395395
for a in aliases.keys():
396396
for v in request.registry.md.store.attribute(aliases[a]):
397-
_links(f'{a}/{quote_plus(v)}')
397+
_links(f'{a}/{quote(v)}')
398398

399399
response = Response(dumps(jrd, default=json_serializer))
400400
response.headers['Content-Type'] = 'application/json'

src/pyff/builtins.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from datetime import datetime
1616
from io import BytesIO
1717
from typing import Optional
18-
from urllib.parse import quote_plus, urlparse
18+
from urllib.parse import quote, urlparse
1919

2020
import xmlsec
2121
from lxml import etree
@@ -539,7 +539,7 @@ def _nop(x):
539539

540540
enc = _nop
541541
if req.args.get('urlencode_filenames'):
542-
enc = quote_plus
542+
enc = quote
543543

544544
if output_file is None:
545545
return req.t

0 commit comments

Comments
 (0)