File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -165,8 +165,20 @@ def is_email(string: celtypes.Value) -> celpy.Result:
165165
166166def is_uri (string : celtypes .Value ) -> celpy .Result :
167167 url = urlparse .urlparse (string )
168- if not all ([url .scheme , url .netloc , url .path ]):
169- return celtypes .BoolType (False )
168+ # urlparse correctly reads the scheme from URNs but parses everything
169+ # after (except the query string) as the path.
170+ if url .scheme == "urn" :
171+ if not (url .path ):
172+ return celtypes .BoolType (False )
173+ else :
174+ if not all ([url .scheme , url .netloc , url .path ]):
175+ return celtypes .BoolType (False )
176+
177+ # If the query string contains percent-encoding, then try to decode it.
178+ # unquote will return the same string if it is improperly encoded.
179+ if "%" in url .query :
180+ return celtypes .BoolType (urlparse .unquote (url .query ) != url .query )
181+
170182 return celtypes .BoolType (True )
171183
172184
You can’t perform that action at this time.
0 commit comments