Skip to content

Commit

Permalink
Merge pull request #1 from NextThought/remove_slash_from_segment
Browse files Browse the repository at this point in the history
Make sure we encode slashes in segments since they are not safe for t…
  • Loading branch information
jzuech3 authored Jul 13, 2018
2 parents 5222fb4 + 5025dfb commit 4c98d57
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions src/nti/traversal/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
@see: https://github.com/Pylons/pyramid/blob/1.8-branch/pyramid/compat.py
@see: https://github.com/Pylons/pyramid/blob/1.8-branch/pyramid/encode.py
@see: https://github.com/Pylons/pyramid/blob/1.8-branch/pyramid/traversal.py
.. $Id$
"""

Expand All @@ -24,10 +24,8 @@
except ImportError: # pragma: no cover
_segment_cache = {}

try:
from webob.request import PATH_SAFE as PATH_SEGMENT_SAFE
except ImportError: # pragma: no cover
PATH_SEGMENT_SAFE = "/~!$&'()*+,;=:@"

PATH_SEGMENT_SAFE = "~!$&'()*+,;=:@"


def url_quote(val, safe=''): # bw compat api
Expand All @@ -42,7 +40,7 @@ def url_quote(val, safe=''): # bw compat api

if six.PY2:
def native_(s, encoding='latin-1', errors='strict'):
"""
"""
If ``s`` is an instance of ``text_type``, return
``s.encode(encoding, errors)``, otherwise return ``str(s)``
"""
Expand All @@ -51,7 +49,7 @@ def native_(s, encoding='latin-1', errors='strict'):
return str(s)
else: # pragma: no cover
def native_(s, encoding='latin-1', errors='strict'):
"""
"""
If ``s`` is an instance of ``text_type``, return
``s``, otherwise return ``str(s, encoding, errors)``
"""
Expand All @@ -62,7 +60,7 @@ def native_(s, encoding='latin-1', errors='strict'):

if six.PY2:
def quote_path_segment(segment, safe=PATH_SEGMENT_SAFE):
"""
"""
Return a quoted representation of a 'path segment'
"""
try:
Expand All @@ -76,7 +74,7 @@ def quote_path_segment(segment, safe=PATH_SEGMENT_SAFE):
return result
else: # pragma: no cover
def quote_path_segment(segment, safe=PATH_SEGMENT_SAFE):
"""
"""
Return a quoted representation of a 'path segment'
"""
try:
Expand Down

0 comments on commit 4c98d57

Please sign in to comment.