Skip to content

Commit

Permalink
Merge pull request #241 from chezou/requote
Browse files Browse the repository at this point in the history
fix: requote URL avoid quoting percent twice
  • Loading branch information
chezou authored Jun 4, 2020
2 parents 2d445d9 + 8d9c9eb commit 6f835b7
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions tabula/file_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@
import shutil
import uuid
from tempfile import gettempdir
from urllib.parse import quote, urlparse, uses_netloc, uses_params, uses_relative
from urllib.parse import (
quote,
unquote,
urlparse,
uses_netloc,
uses_params,
uses_relative,
)
from urllib.request import Request, urlopen

_VALID_URLS = set(uses_relative + uses_netloc + uses_params)
Expand Down Expand Up @@ -31,9 +38,10 @@ def localize_file(path_or_buffer, user_agent=None, suffix=".pdf"):
"""

path_or_buffer = _stringify_path(path_or_buffer)
safe_with_percent = "!#$%&'()*+,/:;=?@[]~"

if _is_url(path_or_buffer):
path_or_buffer = quote(path_or_buffer, safe="/:")
path_or_buffer = quote(unquote(path_or_buffer), safe=safe_with_percent)
if user_agent:
req = urlopen(_create_request(path_or_buffer, user_agent))
else:
Expand Down

0 comments on commit 6f835b7

Please sign in to comment.