fix: use is_valid for cookie url validation (#18770)
Use is_valid instead of is_empty to validate url on cookies.set().
This commit is contained in:
parent
44ea7ab093
commit
83c3f71980
2 changed files with 2 additions and 2 deletions
|
@ -258,7 +258,7 @@ v8::Local<v8::Promise> Cookies::Set(const base::DictionaryValue& details) {
|
||||||
: base::Time::UnixEpoch();
|
: base::Time::UnixEpoch();
|
||||||
|
|
||||||
GURL url(url_string ? *url_string : "");
|
GURL url(url_string ? *url_string : "");
|
||||||
if (url.is_empty()) {
|
if (!url.is_valid()) {
|
||||||
promise.RejectWithErrorMessage(InclusionStatusToString(
|
promise.RejectWithErrorMessage(InclusionStatusToString(
|
||||||
net::CanonicalCookie::CookieInclusionStatus::EXCLUDE_INVALID_DOMAIN));
|
net::CanonicalCookie::CookieInclusionStatus::EXCLUDE_INVALID_DOMAIN));
|
||||||
return handle;
|
return handle;
|
||||||
|
|
|
@ -84,7 +84,7 @@ the response.
|
||||||
#### `cookies.set(details)`
|
#### `cookies.set(details)`
|
||||||
|
|
||||||
* `details` Object
|
* `details` Object
|
||||||
* `url` String - The url to associate the cookie with. An error is thrown if the url is invalid.
|
* `url` String - The url to associate the cookie with. The promise will be rejected if the url is invalid.
|
||||||
* `name` String (optional) - The name of the cookie. Empty by default if omitted.
|
* `name` String (optional) - The name of the cookie. Empty by default if omitted.
|
||||||
* `value` String (optional) - The value of the cookie. Empty by default if omitted.
|
* `value` String (optional) - The value of the cookie. Empty by default if omitted.
|
||||||
* `domain` String (optional) - The domain of the cookie; this will be normalized with a preceding dot so that it's also valid for subdomains. Empty by default if omitted.
|
* `domain` String (optional) - The domain of the cookie; this will be normalized with a preceding dot so that it's also valid for subdomains. Empty by default if omitted.
|
||||||
|
|
Loading…
Reference in a new issue