From 5c750e8b0c406f4d7cd3c1aac2282ea4deffe9b3 Mon Sep 17 00:00:00 2001 From: Gregory Soutade Date: Sat, 16 Jan 2016 08:43:29 +0100 Subject: [PATCH] Remove final slashes for referers --- iwla.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/iwla.py b/iwla.py index caaa7d1..c72c5e1 100755 --- a/iwla.py +++ b/iwla.py @@ -148,7 +148,7 @@ class IWLA(object): self.log_re = re.compile(self.log_format_extracted) self.uri_re = re.compile(r'(?P[^\?#]+)(\?(?P[^#]+))?(#.*)?') self.domain_name_re = re.compile(r'.*%s' % conf.domain_name) - self.normalize_uri_final_slashes = re.compile(r'/+$') + self.final_slashes_re = re.compile(r'/+$') self.plugins = [(conf.PRE_HOOK_DIRECTORY , conf.pre_analysis_hooks), (conf.POST_HOOK_DIRECTORY , conf.post_analysis_hooks), (conf.DISPLAY_HOOK_DIRECTORY , conf.display_hooks)] @@ -337,9 +337,13 @@ class IWLA(object): def _normalizeURI(self, uri): if uri == '/': return uri - uri = self.normalize_uri_final_slashes.sub('/', uri) + uri = self.final_slashes_re.sub('/', uri) return uri + def _removeFinalSlashes(self, uri): + if uri == '/': return uri + return self.final_slashes_re.sub('', uri) + def _normalizeParameters(self, parameters): # No parameters if parameters == '?': return None @@ -368,7 +372,7 @@ class IWLA(object): referer_groups = self.uri_re.match(hit['http_referer']) if referer_groups: hit['extract_referer'] = referer_groups.groupdict() - hit['extract_referer']['extract_uri'] = self._normalizeURI(hit['extract_referer']['extract_uri']) + hit['extract_referer']['extract_uri'] = self._removeFinalSlashes(hit['extract_referer']['extract_uri']) hit['extract_referer']['extract_parameters'] = self._normalizeParameters(hit['extract_referer']['extract_parameters']) return True