urlunparse():  Do not add a leading slash to the path if it is empty.

urljoin():  Make this conform to RFC 1808 for all examples given in that
            RFC (both "Normal" and "Abnormal"), so long as that RFC does
            not conflict the older RFC 1630, which also specified
            relative URL resolution.

This closes SF bug #110832 (Jitterbug PR#194).
diff --git a/Lib/urlparse.py b/Lib/urlparse.py
index d927b7e..b747bc6 100644
--- a/Lib/urlparse.py
+++ b/Lib/urlparse.py
@@ -114,7 +114,7 @@
 	originally had redundant delimiters, e.g. a ? with an empty query
 	(the draft states that these are equivalent)."""
 	if netloc or (scheme in uses_netloc and url[:2] == '//'):
-		if url[:1] != '/': url = '/' + url
+		if url and url[:1] != '/': url = '/' + url
 		url = '//' + (netloc or '') + url
 	if scheme:
 		url = scheme + ':' + url
@@ -131,13 +131,14 @@
 	interpretation of the latter."""
 	if not base:
 		return url
+	if not url:
+		return base
 	bscheme, bnetloc, bpath, bparams, bquery, bfragment = \
 		urlparse(base, '', allow_fragments)
 	scheme, netloc, path, params, query, fragment = \
 		urlparse(url, bscheme, allow_fragments)
 	if scheme != bscheme or scheme not in uses_relative:
-		return urlunparse((scheme, netloc, path,
-				   params, query, fragment))
+		return url
 	if scheme in uses_netloc:
 		if netloc:
 			return urlunparse((scheme, netloc, path,
@@ -147,8 +148,12 @@
 		return urlunparse((scheme, netloc, path,
 				   params, query, fragment))
 	if not path:
+		if not params:
+			params = bparams
+			if not query:
+				query = bquery
 		return urlunparse((scheme, netloc, bpath,
-				   params, query or bquery, fragment))
+				   params, query, fragment))
 	segments = bpath.split('/')[:-1] + path.split('/')
 	# XXX The stuff below is bogus in various ways...
 	if segments[-1] == '.':
@@ -159,13 +164,14 @@
 		i = 1
 		n = len(segments) - 1
 		while i < n:
-			if segments[i] == '..' and segments[i-1]:
+			if (segments[i] == '..'
+			    and segments[i-1] not in ('', '..')):
 				del segments[i-1:i+1]
 				break
 			i = i+1
 		else:
 			break
-	if len(segments) == 2 and segments[1] == '..' and segments[0] == '':
+	if segments == ['', '..']:
 		segments[-1] = ''
 	elif len(segments) >= 2 and segments[-1] == '..':
 		segments[-2:] = ['']