mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 22:01:30 +00:00
Bug 562310 Part 6: Convert C-string version (nsCCommaSeparatedTokenizer) into generic nsCCharSeparatedTokenizer class, too. r=roc
This commit is contained in:
parent
3749f1139c
commit
8c1dcec454
@ -291,7 +291,7 @@ nsCrossSiteListenerProxy::CheckRequestApproved(nsIRequest* aRequest,
|
||||
headerVal);
|
||||
PRBool foundMethod = mPreflightMethod.EqualsLiteral("GET") ||
|
||||
mPreflightMethod.EqualsLiteral("POST");
|
||||
nsCCommaSeparatedTokenizer methodTokens(headerVal);
|
||||
nsCCharSeparatedTokenizer methodTokens(headerVal, ',');
|
||||
while(methodTokens.hasMoreTokens()) {
|
||||
const nsDependentCSubstring& method = methodTokens.nextToken();
|
||||
if (method.IsEmpty()) {
|
||||
@ -310,7 +310,7 @@ nsCrossSiteListenerProxy::CheckRequestApproved(nsIRequest* aRequest,
|
||||
http->GetResponseHeader(NS_LITERAL_CSTRING("Access-Control-Allow-Headers"),
|
||||
headerVal);
|
||||
nsTArray<nsCString> headers;
|
||||
nsCCommaSeparatedTokenizer headerTokens(headerVal);
|
||||
nsCCharSeparatedTokenizer headerTokens(headerVal, ',');
|
||||
while(headerTokens.hasMoreTokens()) {
|
||||
const nsDependentCSubstring& header = headerTokens.nextToken();
|
||||
if (header.IsEmpty()) {
|
||||
|
@ -382,7 +382,7 @@ nsACProxyListener::AddResultToCache(nsIRequest *aRequest)
|
||||
http->GetResponseHeader(NS_LITERAL_CSTRING("Access-Control-Allow-Methods"),
|
||||
headerVal);
|
||||
|
||||
nsCCommaSeparatedTokenizer methods(headerVal);
|
||||
nsCCharSeparatedTokenizer methods(headerVal, ',');
|
||||
while(methods.hasMoreTokens()) {
|
||||
const nsDependentCSubstring& method = methods.nextToken();
|
||||
if (method.IsEmpty()) {
|
||||
@ -412,7 +412,7 @@ nsACProxyListener::AddResultToCache(nsIRequest *aRequest)
|
||||
http->GetResponseHeader(NS_LITERAL_CSTRING("Access-Control-Allow-Headers"),
|
||||
headerVal);
|
||||
|
||||
nsCCommaSeparatedTokenizer headers(headerVal);
|
||||
nsCCharSeparatedTokenizer headers(headerVal, ',');
|
||||
while(headers.hasMoreTokens()) {
|
||||
const nsDependentCSubstring& header = headers.nextToken();
|
||||
if (header.IsEmpty()) {
|
||||
|
@ -2263,7 +2263,7 @@ void nsSSLIOLayerHelpers::setRenegoUnrestrictedSites(const nsCString &str)
|
||||
|
||||
mRenegoUnrestrictedSites->Init(1);
|
||||
|
||||
nsCCommaSeparatedTokenizer toker(str);
|
||||
nsCCharSeparatedTokenizer toker(str, ',');
|
||||
|
||||
while (toker.hasMoreTokens()) {
|
||||
const nsCSubstring &host = toker.nextToken();
|
||||
|
@ -162,10 +162,12 @@ private:
|
||||
}
|
||||
};
|
||||
|
||||
class nsCCommaSeparatedTokenizer
|
||||
class nsCCharSeparatedTokenizer
|
||||
{
|
||||
public:
|
||||
nsCCommaSeparatedTokenizer(const nsCSubstring& aSource)
|
||||
nsCCharSeparatedTokenizer(const nsCSubstring& aSource,
|
||||
char aSeparatorChar)
|
||||
: mSeparatorChar(aSeparatorChar)
|
||||
{
|
||||
aSource.BeginReading(mIter);
|
||||
aSource.EndReading(mEnd);
|
||||
@ -190,9 +192,10 @@ public:
|
||||
{
|
||||
nsCSubstring::const_char_iterator end = mIter, begin = mIter;
|
||||
|
||||
// Search until we hit comma or end
|
||||
while (mIter != mEnd && *mIter != ',') {
|
||||
while (mIter != mEnd && !isWhitespace(*mIter) && *mIter != ',') {
|
||||
// Search until we hit separator or end.
|
||||
while (mIter != mEnd && *mIter != mSeparatorChar) {
|
||||
while (mIter != mEnd &&
|
||||
!isWhitespace(*mIter) && *mIter != mSeparatorChar) {
|
||||
++mIter;
|
||||
}
|
||||
end = mIter;
|
||||
@ -202,9 +205,9 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
// Skip comma
|
||||
// Skip separator (and any whitespace after it).
|
||||
if (mIter != mEnd) {
|
||||
NS_ASSERTION(*mIter == ',', "Ended loop too soon");
|
||||
NS_ASSERTION(*mIter == mSeparatorChar, "Ended loop too soon");
|
||||
++mIter;
|
||||
|
||||
while (mIter != mEnd && isWhitespace(*mIter)) {
|
||||
@ -217,6 +220,7 @@ public:
|
||||
|
||||
private:
|
||||
nsCSubstring::const_char_iterator mIter, mEnd;
|
||||
char mSeparatorChar;
|
||||
|
||||
PRBool isWhitespace(unsigned char aChar)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user