diff --git a/caps/OriginAttributes.cpp b/caps/OriginAttributes.cpp index 93137d5dabf9..bec78276187b 100644 --- a/caps/OriginAttributes.cpp +++ b/caps/OriginAttributes.cpp @@ -251,11 +251,8 @@ OriginAttributes::PopulateFromSuffix(const nsACString& aStr) return false; } - URLParams params; - params.ParseInput(Substring(aStr, 1, aStr.Length() - 1)); - PopulateFromSuffixIterator iterator(this); - return params.ForEach(iterator); + return URLParams::Parse(Substring(aStr, 1, aStr.Length() - 1), iterator); } bool diff --git a/dom/base/BodyUtil.cpp b/dom/base/BodyUtil.cpp index ba304905e9d8..57dcec80c376 100644 --- a/dom/base/BodyUtil.cpp +++ b/dom/base/BodyUtil.cpp @@ -469,12 +469,9 @@ BodyUtil::ConsumeFormData(nsIGlobalObject* aParent, const nsCString& aMimeType, } if (isValidUrlEncodedMimeType) { - URLParams params; - params.ParseInput(aStr); - RefPtr fd = new FormData(aParent); FillFormIterator iterator(fd); - DebugOnly status = params.ForEach(iterator); + DebugOnly status = URLParams::Parse(aStr, iterator); MOZ_ASSERT(status); return fd.forget(); diff --git a/dom/url/URLSearchParams.cpp b/dom/url/URLSearchParams.cpp index a63a35f2da4b..272ca507c377 100644 --- a/dom/url/URLSearchParams.cpp +++ b/dom/url/URLSearchParams.cpp @@ -163,6 +163,14 @@ URLParams::DecodeString(const nsACString& aInput, nsAString& aOutput) ConvertString(unescaped, aOutput); } +/* static */ bool +URLParams::Parse(const nsACString& aInput, ForEachIterator& aIterator) +{ + URLParams params; + params.ParseInput(aInput); + return params.ForEach(aIterator); +} + void URLParams::ParseInput(const nsACString& aInput) { diff --git a/dom/url/URLSearchParams.h b/dom/url/URLSearchParams.h index 239c8bc3c503..ff3904b93b5a 100644 --- a/dom/url/URLSearchParams.h +++ b/dom/url/URLSearchParams.h @@ -50,6 +50,9 @@ public: URLParamsIterator(const nsString& aName, const nsString& aValue) = 0; }; + static bool + Parse(const nsACString& aInput, ForEachIterator& aIterator); + void ParseInput(const nsACString& aInput);