Skip to content

Commit

Permalink
Remove python2 urllib imports
Browse files Browse the repository at this point in the history
Fix for "javascript:" script links in identifier
  • Loading branch information
OzzieIsaacs committed Dec 30, 2021
1 parent f39dc10 commit 47f5e2f
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 18 deletions.
3 changes: 3 additions & 0 deletions cps/db.py
Expand Up @@ -23,6 +23,7 @@
import ast
import json
from datetime import datetime
from urllib.parse import quote

from sqlalchemy import create_engine
from sqlalchemy import Table, Column, ForeignKey, CheckConstraint
Expand Down Expand Up @@ -166,6 +167,8 @@ def __repr__(self):
return u"https://portal.issn.org/resource/ISSN/{0}".format(self.val)
elif format_type == "isfdb":
return u"http://www.isfdb.org/cgi-bin/pl.cgi?{0}".format(self.val)
elif self.val.lower().startswith("javascript:"):
return quote(self.val)
else:
return u"{0}".format(self.val)

Expand Down
5 changes: 1 addition & 4 deletions cps/helper.py
Expand Up @@ -38,11 +38,8 @@
from werkzeug.datastructures import Headers
from werkzeug.security import generate_password_hash
from markupsafe import escape
from urllib.parse import quote

try:
from urllib.parse import quote
except ImportError:
from urllib import quote

try:
import unidecode
Expand Down
6 changes: 1 addition & 5 deletions cps/kobo.py
Expand Up @@ -23,11 +23,7 @@
import uuid
from time import gmtime, strftime
import json

try:
from urllib import unquote
except ImportError:
from urllib.parse import unquote
from urllib.parse import unquote

from flask import (
Blueprint,
Expand Down
6 changes: 2 additions & 4 deletions cps/redirect.py
Expand Up @@ -27,10 +27,8 @@

# http://flask.pocoo.org/snippets/62/

try:
from urllib.parse import urlparse, urljoin
except ImportError:
from urlparse import urlparse, urljoin
from urllib.parse import urlparse, urljoin


from flask import request, url_for, redirect

Expand Down
7 changes: 2 additions & 5 deletions cps/services/SyncToken.py
Expand Up @@ -21,11 +21,8 @@
from base64 import b64decode, b64encode
from jsonschema import validate, exceptions, __version__
from datetime import datetime
try:
# pylint: disable=unused-import
from urllib import unquote
except ImportError:
from urllib.parse import unquote

from urllib.parse import unquote

from flask import json
from .. import logger
Expand Down

0 comments on commit 47f5e2f

Please sign in to comment.