mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 15:23:51 +00:00
Bug 1299373. Scripts with an empty src attribute should not execute. r=bkelly
This commit is contained in:
parent
4e2656ef99
commit
e664d8bcd3
@ -139,6 +139,10 @@ HTMLScriptElement::SetText(const nsAString& aValue, ErrorResult& rv)
|
||||
|
||||
NS_IMPL_STRING_ATTR(HTMLScriptElement, Charset, charset)
|
||||
NS_IMPL_BOOL_ATTR(HTMLScriptElement, Defer, defer)
|
||||
// If this ever gets changed to return "" if the attr value is "" (see
|
||||
// https://github.com/whatwg/html/issues/1739 for why it might not get changed),
|
||||
// it may be worth it to use GetSrc instead of GetAttr and manual
|
||||
// NewURIWithDocumentCharset in FreezeUriAsyncDefer.
|
||||
NS_IMPL_URI_ATTR(HTMLScriptElement, Src, src)
|
||||
NS_IMPL_STRING_ATTR(HTMLScriptElement, Type, type)
|
||||
NS_IMPL_STRING_ATTR(HTMLScriptElement, HtmlFor, _for)
|
||||
@ -270,11 +274,17 @@ HTMLScriptElement::FreezeUriAsyncDefer()
|
||||
}
|
||||
|
||||
// variation of this code in nsSVGScriptElement - check if changes
|
||||
// need to be transfered when modifying
|
||||
if (HasAttr(kNameSpaceID_None, nsGkAtoms::src)) {
|
||||
nsAutoString src;
|
||||
GetSrc(src);
|
||||
NS_NewURI(getter_AddRefs(mUri), src);
|
||||
// need to be transfered when modifying. Note that we don't use GetSrc here
|
||||
// because it will return the base URL when the attr value is "".
|
||||
nsAutoString src;
|
||||
if (GetAttr(kNameSpaceID_None, nsGkAtoms::src, src)) {
|
||||
// Empty src should be treated as invalid URL.
|
||||
if (!src.IsEmpty()) {
|
||||
nsCOMPtr<nsIURI> baseURI = GetBaseURI();
|
||||
nsContentUtils::NewURIWithDocumentCharset(getter_AddRefs(mUri),
|
||||
src, OwnerDoc(), baseURI);
|
||||
}
|
||||
|
||||
// At this point mUri will be null for invalid URLs.
|
||||
mExternal = true;
|
||||
|
||||
|
@ -154,8 +154,12 @@ SVGScriptElement::FreezeUriAsyncDefer()
|
||||
mStringAttributes[XLINK_HREF].GetAnimValue(src, this);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIURI> baseURI = GetBaseURI();
|
||||
NS_NewURI(getter_AddRefs(mUri), src, nullptr, baseURI);
|
||||
// Empty src should be treated as invalid URL.
|
||||
if (!src.IsEmpty()) {
|
||||
nsCOMPtr<nsIURI> baseURI = GetBaseURI();
|
||||
NS_NewURI(getter_AddRefs(mUri), src, nullptr, baseURI);
|
||||
}
|
||||
|
||||
// At this point mUri will be null for invalid URLs.
|
||||
mExternal = true;
|
||||
}
|
||||
|
@ -1,5 +0,0 @@
|
||||
[empty-with-base.html]
|
||||
type: testharness
|
||||
[Script src with an empty URL]
|
||||
expected: FAIL
|
||||
|
@ -1,5 +0,0 @@
|
||||
[empty.html]
|
||||
type: testharness
|
||||
[Script src with an empty URL]
|
||||
expected: FAIL
|
||||
|
@ -1,3 +0,0 @@
|
||||
[137.html]
|
||||
type: testharness
|
||||
expected: ERROR
|
Loading…
Reference in New Issue
Block a user