15
15
import re
16
16
import sys
17
17
18
+ from collections import defaultdict
19
+ from urllib .parse import unquote
18
20
from warnings import warn
19
21
20
22
from HTTPExceptions import HTTPNotFound , HTTPMovedPermanently
21
23
from MiscUtils .ParamFactory import ParamFactory
22
- from WebUtils .Funcs import urlDecode
23
24
24
25
debug = False
25
26
@@ -249,7 +250,7 @@ def parse(self, trans, requestPath):
249
250
through `Request.serverSidePath` and `Request.contextName`).
250
251
"""
251
252
# This is a hack... should probably go in the Transaction class:
252
- trans ._fileParserInitSeen = {}
253
+ trans ._fileParserInitSeen = defaultdict ( set )
253
254
# If there is no path, redirect to the root path:
254
255
req = trans .request ()
255
256
if not requestPath :
@@ -259,7 +260,7 @@ def parse(self, trans, requestPath):
259
260
p += "?" + q
260
261
raise HTTPMovedPermanently (location = p )
261
262
# Determine the context name:
262
- context = [_f for _f in requestPath .split ('/' ) if _f ]
263
+ context = [p for p in requestPath .split ('/' ) if p ]
263
264
if requestPath .endswith ('/' ):
264
265
context .append ('' )
265
266
parts = []
@@ -345,7 +346,9 @@ def parse(self, trans, requestPath):
345
346
req = trans .request ()
346
347
347
348
# First decode the URL, since we are dealing with filenames here:
348
- requestPath = urlDecode (requestPath )
349
+ # We must use unquote instead of unquote_plus, because decoding
350
+ # the plus sign should only happen for the query string.
351
+ requestPath = unquote (requestPath )
349
352
350
353
result = self .parseInit (trans , requestPath )
351
354
if result is not None :
@@ -620,7 +623,7 @@ def parseInit(self, trans, requestPath):
620
623
self ._initModule = self .initModule ()
621
624
mod = self ._initModule
622
625
623
- seen = trans ._fileParserInitSeen . setdefault ( self ._path , set ())
626
+ seen = trans ._fileParserInitSeen [ self ._path ]
624
627
625
628
if ('urlTransactionHook' not in seen
626
629
and hasattr (mod , 'urlTransactionHook' )):
0 commit comments