--- /home/Kevin/Tools/w3af.orig/core/data/parsers/urlParser.py	2008-08-23 04:52:13.000000000 +0200
+++ urlParser.py	2008-12-04 08:42:15.000000000 +0100
@@ -44,11 +44,23 @@
     @parameter uri: The uri to analize.
     @return: True if the URI has a query string.
     '''
-    scheme, domain, path, x1, qs, x3 = _uparse.urlparse( uri )
+    scheme, domain, path, param, qs, x3 = _uparse.urlparse( uri )
     if qs != '':
         return True
     return False
 
+def hasParameter( uri ):
+    '''
+    Analizes the uri to check for a session id.
+    
+    @parameter uri: The uri to analize.
+    @return: True if the URI has a session id.
+    '''
+    scheme, domain, path, param, qs, x3 = _uparse.urlparse( uri )
+    if param != '':
+        return True
+    return False
+
 def getQueryString( url, ignoreExceptions=True ):
     '''
     Parses the query string and returns a dict.
@@ -61,7 +73,7 @@
     parsedQs = None
     result = queryString()
     if hasQueryString( url ):
-        scheme, domain, path, x1, qs, x3 = _uparse.urlparse( url )
+        scheme, domain, path, param, qs, x3 = _uparse.urlparse( url )
         try:
             parsedQs = cgi.parse_qs( qs ,keep_blank_values=True,strict_parsing=True)
         except Exception, e:
@@ -80,7 +92,11 @@
         - input url : http://localhost/foo.asp?xx=yy&bb=dd#fragment
         - output url string : http://localhost/foo.asp
     '''
-    scheme, domain, path, x1, qs, x3 = _uparse.urlparse( url )
+    scheme, domain, path, param, qs, x3 = _uparse.urlparse( url )
+
+    if param != '':
+      return scheme+'://'+domain+path+';'+param
+    
     return scheme+'://'+domain+path
 
 def removeFragment(  url ):
@@ -90,13 +106,33 @@
         - input url : http://localhost/foo.asp?xx=yy&bb=dd#fragment
         - output url string : http://localhost/foo.asp?xx=yy&bb=dd
     '''
-    scheme, domain, path, x1, qs, x3 = _uparse.urlparse( url )
+    scheme, domain, path, param, qs, x3 = _uparse.urlparse( url )
+    
+    res = scheme+'://'+domain+path
+    
+    if param != '':
+      res = res+';'+param
+
     if qs != '':
-        res = scheme+'://'+domain+path+'?'+qs
-    else:
+        res = res+'?'+qs
+    return res
+
+def removeParameter( url ):
+    '''
+    @parameter url: The url with parameter
+    @return: Returns a string contaning the URL without the parameter. Example :
+        - input url : http://localhost/foo.asp;jsessionid=ABDR1234?xx=yy&bb=dd#fragment
+        - output url string : http://localhost/foo.asp?xx=yy&bb=dd
+    '''
+    scheme, domain, path, param, qs, x3 = _uparse.urlparse( url )
+    
         res = scheme+'://'+domain+path
+
+    if qs != '':
+        res = res+'?'+qs
     return res
     
+    
 def baseUrl(  url ):
     '''
     @parameter url: The url with the query string.
@@ -105,7 +141,7 @@
         - input url : http://localhost/dir1/foo.asp?xx=yy&bb=dd
         - output url string : http://localhost/
     '''
-    scheme, domain, path, x1, qs, x3 = _uparse.urlparse( url )
+    scheme, domain, path, param, qs, x3 = _uparse.urlparse( url )
     return scheme+'://'+domain + '/'
 
 
@@ -153,7 +189,7 @@
     '''        
     if relative.find('//') == 0:
         # This special case had to be generated cause of some pykto tests
-        scheme, domain, path, x1, qs, x3 = _uparse.urlparse( baseurl )
+        scheme, domain, path, param, qs, x3 = _uparse.urlparse( baseurl )
         lastSlash = path.rfind( '/' )
         if lastSlash != 0:
             # I have more than one /
@@ -175,7 +211,7 @@
     @parameter url: The url to parse.
     @return: Returns the domain name for the url.
     '''
-    scheme, domain, path, x1, qs, x3 = _uparse.urlparse( url )
+    scheme, domain, path, param, qs, x3 = _uparse.urlparse( url )
     domain = domain.split(':')[0]
     return domain
     
@@ -187,7 +223,7 @@
     @parameter url: The url to parse.
     @return: Returns the net location for the url.
     '''
-    scheme, domain, path, x1, qs, x3 = _uparse.urlparse( url )
+    scheme, domain, path, param, qs, x3 = _uparse.urlparse( url )
     return domain
 
 def getProtocol( url ):
@@ -195,9 +231,33 @@
     @parameter url: The url to parse.
     @return: Returns the domain name for the url.
     '''
-    scheme, domain, path, x1, qs, x3 = _uparse.urlparse( url )
+    scheme, domain, path, param, qs, x3 = _uparse.urlparse( url )
     return scheme
 
+def getParameter( url ):
+    '''
+    @parameter url: The url to parse.
+    @return: Returns the session id inside the url.
+    '''
+    scheme, domain, path, param, qs, x3 = _uparse.urlparse( url )
+    return param
+
+def setParameter( url, value ):
+    '''
+    @parameter url: The url to parse.
+    @parameter sessionid: The session id to set.
+    @return: Returns the url containing the session id.
+    '''
+    scheme, domain, path, param, qs, x3 = _uparse.urlparse( url )
+
+    res = scheme+'://'+domain+path
+    res = res+';'+value
+
+    if qs != '':
+        res = res+'?'+qs
+    
+    return res
+
 def getRootDomain( input ):
     '''
     Get the root domain name. Examples:
@@ -319,7 +379,7 @@
     'http://localhost/abc/'
     >>> 
     '''
-    scheme, domain, path, x1, qs, x3 = _uparse.urlparse( url )
+    scheme, domain, path, param, qs, x3 = _uparse.urlparse( url )
     if path:
         res = scheme + '://' +domain+ path[:path.rfind('/')+1]
     else:
@@ -340,7 +400,7 @@
     >>> getFileName('http://localhost/def/abc.html')
     'abc.html'
     '''
-    scheme, domain, path, x1, qs, x3 = _uparse.urlparse( url )
+    scheme, domain, path, param, qs, x3 = _uparse.urlparse( url )
     return path[path.rfind('/')+1:]
 
 def getExtension( url ):
@@ -360,7 +420,7 @@
     @parameter url: The url to parse.
     @return: Returns the domain name and the path for the url.
     '''
-    scheme, domain, path, x1, qs, x3 = _uparse.urlparse( url )
+    scheme, domain, path, param, qs, x3 = _uparse.urlparse( url )
     return domain+ path[:path.rfind('/')+1]
     
 def getPath( url):
@@ -372,7 +432,7 @@
         Output:
             /pepe/0a0a
     '''
-    scheme, domain, path, x1, qs, x3 = _uparse.urlparse( url )
+    scheme, domain, path, param, qs, x3 = _uparse.urlparse( url )
     return path
     
 def getPathQs( url ):
@@ -383,11 +443,16 @@
     @parameter url: The url to parse.
     @return: Returns the domain name and the path for the url.
     '''
-    scheme, domain, path, x1, qs, x3 = _uparse.urlparse( url )
-    if qs != '':
-        res = path + '?' + qs
-    else:
+    scheme, domain, path, param, qs, x3 = _uparse.urlparse( url )
+
         res = path
+
+    if param != '':
+      res = res+';'+param
+
+    if qs != '':
+      res = res+'?'+qs
+    
     return res
     
 def urlDecode( url ):
