File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -165,8 +165,19 @@ 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 ]):
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+ elif not all ([url .scheme , url .netloc , url .path ]):
169174 return celtypes .BoolType (False )
175+
176+ # If the query string contains percent-encoding, then try to decode it.
177+ # unquote will return the same string if it is improperly encoded.
178+ if "%" in url .query :
179+ return celtypes .BoolType (urlparse .unquote (url .query ) != url .query )
180+
170181 return celtypes .BoolType (True )
171182
172183
You can’t perform that action at this time.
0 commit comments