From 9b8018143bd7fde04c039027c1da1ad1a5561e07 Mon Sep 17 00:00:00 2001 From: "timeless%mac.com" Date: Wed, 16 Jan 2002 07:31:45 +0000 Subject: [PATCH] Bug 117740 bad style in Cut calls in nsJARURI::SetSpec r=redfive sr=jag --- modules/libjar/nsJARURI.cpp | 11 +++++------ netwerk/protocol/jar/src/nsJARURI.cpp | 11 +++++------ 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/modules/libjar/nsJARURI.cpp b/modules/libjar/nsJARURI.cpp index 38ed6ec5a60..9d8a694df74 100644 --- a/modules/libjar/nsJARURI.cpp +++ b/modules/libjar/nsJARURI.cpp @@ -157,7 +157,8 @@ nsJARURI::SetSpec(const char * aSpec) nsCAutoString jarPath(aSpec); PRInt32 pos = jarPath.RFind(NS_JAR_DELIMITER); - if (pos == -1 || endPos + 1 > (PRUint32)pos) + startPos = (PRUint32) pos; + if (pos == -1 || endPos + 1 > startPos) return NS_ERROR_MALFORMED_URI; jarPath.Cut(pos, jarPath.Length()); @@ -166,12 +167,10 @@ nsJARURI::SetSpec(const char * aSpec) rv = serv->NewURI(jarPath.get(), nsnull, getter_AddRefs(mJARFile)); if (NS_FAILED(rv)) return rv; - nsCAutoString entry(aSpec); - entry.Cut(0, pos + 2); // 2 == strlen(NS_JAR_DELIMITER) - while (entry.Length() && entry.CharAt(0) == '/') - entry.Cut(0,1); // Strip any additional leading slashes from entry path + PRUint32 slashChar=pos + 1; + while (aSpec[++slashChar]=='/'); - rv = serv->ResolveRelativePath(entry.get(), nsnull, &mJAREntry); + rv = serv->ResolveRelativePath(&aSpec[slashChar], nsnull, &mJAREntry); return rv; } diff --git a/netwerk/protocol/jar/src/nsJARURI.cpp b/netwerk/protocol/jar/src/nsJARURI.cpp index 38ed6ec5a60..9d8a694df74 100644 --- a/netwerk/protocol/jar/src/nsJARURI.cpp +++ b/netwerk/protocol/jar/src/nsJARURI.cpp @@ -157,7 +157,8 @@ nsJARURI::SetSpec(const char * aSpec) nsCAutoString jarPath(aSpec); PRInt32 pos = jarPath.RFind(NS_JAR_DELIMITER); - if (pos == -1 || endPos + 1 > (PRUint32)pos) + startPos = (PRUint32) pos; + if (pos == -1 || endPos + 1 > startPos) return NS_ERROR_MALFORMED_URI; jarPath.Cut(pos, jarPath.Length()); @@ -166,12 +167,10 @@ nsJARURI::SetSpec(const char * aSpec) rv = serv->NewURI(jarPath.get(), nsnull, getter_AddRefs(mJARFile)); if (NS_FAILED(rv)) return rv; - nsCAutoString entry(aSpec); - entry.Cut(0, pos + 2); // 2 == strlen(NS_JAR_DELIMITER) - while (entry.Length() && entry.CharAt(0) == '/') - entry.Cut(0,1); // Strip any additional leading slashes from entry path + PRUint32 slashChar=pos + 1; + while (aSpec[++slashChar]=='/'); - rv = serv->ResolveRelativePath(entry.get(), nsnull, &mJAREntry); + rv = serv->ResolveRelativePath(&aSpec[slashChar], nsnull, &mJAREntry); return rv; }