mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 15:23:51 +00:00
Bug 1431924 - Do not use URLParams::ParseInput in PageThumbsProtocol::ParseProtocolURL; r=bz
MozReview-Commit-ID: 79Pg9Vlq8Bu --HG-- extra : rebase_source : 268407fe4f206751c66c66bd378ea8ff112b816d
This commit is contained in:
parent
cd8167d8de
commit
7efbdaade9
@ -216,6 +216,47 @@ URLParams::Parse(const nsACString& aInput, ForEachIterator& aIterator)
|
||||
return true;
|
||||
}
|
||||
|
||||
class MOZ_STACK_CLASS ExtractURLParam final
|
||||
: public URLParams::ForEachIterator
|
||||
{
|
||||
public:
|
||||
explicit ExtractURLParam(const nsAString& aName, nsAString& aValue)
|
||||
: mName(aName), mValue(aValue)
|
||||
{}
|
||||
|
||||
bool URLParamsIterator(const nsAString& aName,
|
||||
const nsAString& aValue) override
|
||||
{
|
||||
if (mName == aName) {
|
||||
mValue = aValue;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
const nsAString& mName;
|
||||
nsAString& mValue;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Extracts the first form-urlencoded parameter named `aName` from `aInput`.
|
||||
* @param aRange The input to parse.
|
||||
* @param aName The name of the parameter to extract.
|
||||
* @param aValue The value of the extracted parameter, void if not found.
|
||||
* @return Whether the parameter was found in the form-urlencoded.
|
||||
*/
|
||||
/* static */ bool
|
||||
URLParams::Extract(const nsACString& aInput,
|
||||
const nsAString& aName,
|
||||
nsAString& aValue)
|
||||
{
|
||||
aValue.SetIsVoid(true);
|
||||
ExtractURLParam iterator(aName, aValue);
|
||||
return !URLParams::Parse(aInput, iterator);
|
||||
}
|
||||
|
||||
class MOZ_STACK_CLASS PopulateIterator final
|
||||
: public URLParams::ForEachIterator
|
||||
{
|
||||
|
@ -53,6 +53,9 @@ public:
|
||||
static bool
|
||||
Parse(const nsACString& aInput, ForEachIterator& aIterator);
|
||||
|
||||
static bool
|
||||
Extract(const nsACString& aInput, const nsAString& aName, nsAString& aValue);
|
||||
|
||||
void
|
||||
ParseInput(const nsACString& aInput);
|
||||
|
||||
|
@ -138,10 +138,9 @@ PageThumbsProtocol::ParseProtocolURL(nsIURI* aURI, nsString& aParsedURL)
|
||||
return NS_ERROR_MALFORMED_URI;
|
||||
}
|
||||
|
||||
URLParams params;
|
||||
params.ParseInput(Substring(path, queryBegins + 1));
|
||||
|
||||
params.Get(NS_LITERAL_STRING("url"), aParsedURL);
|
||||
URLParams::Extract(Substring(path, queryBegins + 1),
|
||||
NS_LITERAL_STRING("url"),
|
||||
aParsedURL);
|
||||
|
||||
// If there's no URL as part of the query params, there will be no thumbnail
|
||||
if (aParsedURL.IsVoid()) {
|
||||
|
Loading…
Reference in New Issue
Block a user