'This method was added to be able to avoid some issues which are
generated by the different way browsers and urlparser.urljoin
join the URLs. A clear example of this is the following case:
baseURL = \'http:/abc/\'
relativeURL = \'/../f00.b4r\'
w3af would try to GET http:/abc/../f00.b4r; while mozilla would
try to get http:/abc/f00.b4r. In some cases, the first is ok,
on other cases the first one doesn\'t even work and return a 403
error message.
So, to sum up, this method takes an URL, and returns a normalized
URL. For the example we were talking before, it will return:
http://abc/f00.b4r
instead of the normal response from urlparser.urljoin:
http://abc/../f00.b4r
Added later: Before performing anything, I also normalize the
net location part of the URL. In some web apps we see things like:
http://host.tld:80/foo/bar
As you may have noticed, the ":80" is redundant, and what\'s even
worse, it can confuse w3af when performing string comparisons:
http://host.tld:80/foo/bar != http://host.tld/foo/bar , and
http://host.tld/foo/bar could also be found by the web_spider
plugin, so we are analyzing the same thing twice.'

@set_changed
def normalize_url(self):

    net_location = self.get_net_location()
    protocol = self.get_protocol()
    at_symb_index = net_location.rfind('@')
    colon_symb_max_index = net_location.rfind(':')
    if (colon_symb_max_index > at_symb_index):
        host = net_location[:colon_symb_max_index]
        port = net_location[(colon_symb_max_index + 1):]
        if (not port):
            msg = 'Expected    protocol    number,    got    an    empty    string    instead.'
            raise ValueError(msg)
        if (not port.isdigit()):
            msg = 'Expected    protocol    number,    got    "%s"    instead.'
            raise ValueError((msg % port))
        if ((int(port) > 65535) or (int(port) < 1)):
            msg = 'Invalid    TCP    port    "%s",    expected    a    number    in    range    1-65535.'
            raise ValueError((msg % port))
        if (((protocol == 'http') and (port == '80')) or ((protocol == 'https') and (port == '443'))):
            net_location = host
        else:
            net_location = ((host + ':') + port)
    path = self.path
    trailer_slash = path.endswith('/')
    tokens = []
    for p in path.split('/'):
        if (not p):
            continue
        elif (p != '..'):
            tokens.append(p)
        elif tokens:
            tokens.pop()
    self.path = ('/'.join(tokens) + ('/' if trailer_slash else ''))
    fixed_url = urlparse.urlunparse((protocol, net_location, self.path, self.params, '', self.fragment))
    (self.scheme, self.netloc, self.path, self.params, _, self.fragment) = urlparse.urlparse(fixed_url)
