1 Index: nsStandardURL.cpp
2 ===================================================================
3 RCS file: /cvs/mozilla/netwerk/base/src/nsStandardURL.cpp,v
4 retrieving revision 1.60.16.2
5 diff -p -u -1 -2 -r1.60.16.2 nsStandardURL.cpp
6 --- 1/netwerk/base/src/nsStandardURL.cpp 17 Feb 2005 23:40:53 -0000 1.60.16.2
7 +++ 2/netwerk/base/src/nsStandardURL.cpp 9 Sep 2005 16:34:46 -0000
8 @@ -403,24 +403,25 @@ nsStandardURL::AppendToBuf(char *buf, PR
9 // 4- update url segment positions and lengths
11 nsStandardURL::BuildNormalizedSpec(const char *spec)
13 // Assumptions: all member URLSegments must be relative the |spec| argument
14 // passed to this function.
16 // buffers for holding escaped url segments (these will remain empty unless
17 // escaping is required).
18 nsCAutoString encUsername;
19 nsCAutoString encPassword;
20 nsCAutoString encHost;
22 nsCAutoString encDirectory;
23 nsCAutoString encBasename;
24 nsCAutoString encExtension;
25 nsCAutoString encParam;
26 nsCAutoString encQuery;
30 // escape each URL segment, if necessary, and calculate approximate normalized
33 PRInt32 approxLen = 3; // includes room for "://"
34 @@ -440,34 +441,36 @@ nsStandardURL::BuildNormalizedSpec(const
35 approxLen += encoder.EncodeSegmentCount(spec, mBasename, esc_FileBaseName, encBasename);
36 approxLen += encoder.EncodeSegmentCount(spec, mExtension, esc_FileExtension, encExtension);
37 approxLen += encoder.EncodeSegmentCount(spec, mParam, esc_Param, encParam);
38 approxLen += encoder.EncodeSegmentCount(spec, mQuery, esc_Query, encQuery);
39 approxLen += encoder.EncodeSegmentCount(spec, mRef, esc_Ref, encRef);
42 // do not escape the hostname, if IPv6 address literal, mHost will
43 // already point to a [ ] delimited IPv6 address literal.
44 // However, perform Unicode normalization on it, as IDN does.
45 mHostEncoding = eEncoding_ASCII;
47 + useEncHost = PR_FALSE;
48 const nsCSubstring& tempHost =
49 Substring(spec + mHost.mPos, spec + mHost.mPos + mHost.mLen);
50 if (IsASCII(tempHost))
51 approxLen += mHost.mLen;
53 mHostEncoding = eEncoding_UTF8;
55 - NS_SUCCEEDED(gIDNService->Normalize(tempHost, encHost)))
56 + NS_SUCCEEDED(gIDNService->Normalize(tempHost, encHost))) {
57 approxLen += encHost.Length();
59 + useEncHost = PR_TRUE;
62 approxLen += mHost.mLen;
68 // generate the normalized URL string
70 mSpec.SetLength(approxLen + 32);
72 mSpec.BeginWriting(buf);
73 @@ -483,25 +486,30 @@ nsStandardURL::BuildNormalizedSpec(const
77 if (mUsername.mLen > 0) {
78 i = AppendSegmentToBuf(buf, i, spec, mUsername, &encUsername);
79 if (mPassword.mLen >= 0) {
81 i = AppendSegmentToBuf(buf, i, spec, mPassword, &encPassword);
86 - i = AppendSegmentToBuf(buf, i, spec, mHost, &encHost);
89 + mHost.mLen = encHost.Length();
90 + i = AppendToBuf(buf, i, encHost.get(), mHost.mLen);
92 + i = AppendSegmentToBuf(buf, i, spec, mHost);
93 net_ToLowerCase(buf + mHost.mPos, mHost.mLen);
94 if (mPort != -1 && mPort != mDefaultPort) {
95 nsCAutoString portbuf;
96 portbuf.AppendInt(mPort);
98 i = AppendToBuf(buf, i, portbuf.get(), portbuf.Length());
102 // record authority length
103 mAuthority.mLen = i - mAuthority.mPos;