зеркало из https://github.com/mozilla/pjs.git
Bug 47191. Trim whitespace from relative spec before constructing absolute URLs. r=jst
This commit is contained in:
Родитель
813f306433
Коммит
a6ad0e1bcd
|
@ -1807,6 +1807,7 @@ nsGenericHTMLElement::GetBaseURL(const nsHTMLValue& aBaseHref,
|
|||
if (eHTMLUnit_String == aBaseHref.GetUnit()) {
|
||||
nsAutoString baseHref;
|
||||
aBaseHref.GetStringValue(baseHref);
|
||||
baseHref.Trim(" \t\n\r");
|
||||
|
||||
nsIURI* url = nsnull;
|
||||
{
|
||||
|
|
|
@ -668,6 +668,9 @@ nsHTMLAnchorElement::GetHrefCString(char* &aBuf)
|
|||
|
||||
if (NS_CONTENT_ATTR_HAS_VALUE ==
|
||||
mInner.GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::href, relURLSpec)) {
|
||||
// Clean up any leading or trailing whitespace
|
||||
relURLSpec.Trim(" \t\n\r");
|
||||
|
||||
// Get base URL.
|
||||
nsCOMPtr<nsIURI> baseURL;
|
||||
mInner.GetBaseURL(*getter_AddRefs(baseURL));
|
||||
|
|
|
@ -511,6 +511,9 @@ nsHTMLAreaElement::GetHrefCString(char* &aBuf)
|
|||
|
||||
if (NS_CONTENT_ATTR_HAS_VALUE ==
|
||||
mInner.GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::href, relURLSpec)) {
|
||||
// Clean up any leading or trailing whitespace
|
||||
relURLSpec.Trim(" \t\n\r");
|
||||
|
||||
// Get base URL.
|
||||
nsCOMPtr<nsIURI> baseURL;
|
||||
mInner.GetBaseURL(*getter_AddRefs(baseURL));
|
||||
|
|
|
@ -688,6 +688,7 @@ nsHTMLImageElement::SetProperty(JSContext *aContext, JSObject *aObj, jsval aID,
|
|||
JSString *jsstring;
|
||||
if ((jsstring = JS_ValueToString(aContext, *aVp)) != nsnull) {
|
||||
src.Assign(NS_REINTERPRET_CAST(const PRUnichar*, JS_GetStringChars(jsstring)));
|
||||
src.Trim(" \t\n\r");
|
||||
}
|
||||
else {
|
||||
src.Truncate();
|
||||
|
@ -834,6 +835,7 @@ nsHTMLImageElement::GetSrc(nsAWritableString& aSrc)
|
|||
|
||||
// Get href= attribute (relative URL).
|
||||
mInner.GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::src, relURLSpec);
|
||||
relURLSpec.Trim(" \t\n\r");
|
||||
|
||||
if (nsnull != baseURL && relURLSpec.Length() > 0) {
|
||||
// Get absolute URL.
|
||||
|
|
|
@ -353,6 +353,9 @@ nsHTMLLinkElement::GetHrefCString(char* &aBuf)
|
|||
|
||||
if (NS_CONTENT_ATTR_HAS_VALUE ==
|
||||
mInner.GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::href, relURLSpec)) {
|
||||
// Clean up any leading or trailing whitespace
|
||||
relURLSpec.Trim(" \t\n\r");
|
||||
|
||||
// Get base URL.
|
||||
nsCOMPtr<nsIURI> baseURL;
|
||||
mInner.GetBaseURL(*getter_AddRefs(baseURL));
|
||||
|
|
|
@ -175,7 +175,7 @@ nsImageFrame::Init(nsIPresContext* aPresContext,
|
|||
}
|
||||
}
|
||||
|
||||
if (NS_CONTENT_ATTR_HAS_VALUE == lowSrcResult && lowSrc.Length() > 0) {
|
||||
if (NS_CONTENT_ATTR_HAS_VALUE == lowSrcResult && lowSrc.Length() > 0) {
|
||||
mLowSrcImageLoader = new nsHTMLImageLoader;
|
||||
if (mLowSrcImageLoader != nsnull) {
|
||||
mLowSrcImageLoader->Init(this, UpdateImageFrame, (void*)mLowSrcImageLoader, baseURL, lowSrc);
|
||||
|
@ -359,6 +359,13 @@ nsImageFrame::Reflow(nsIPresContext* aPresContext,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsImageFrame::CanContinueTextRun(PRBool& aContinueTextRun) const
|
||||
{
|
||||
aContinueTextRun = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Computes the width of the specified string. aMaxWidth specifies the maximum
|
||||
// width available. Once this limit is reached no more characters are measured.
|
||||
// The number of characters that fit within the maximum width are returned in
|
||||
|
|
|
@ -82,6 +82,7 @@ void
|
|||
nsHTMLImageLoader::SetURL(const nsString& aNewSpec)
|
||||
{
|
||||
mURLSpec = aNewSpec;
|
||||
mURLSpec.Trim(" \t\n\r");
|
||||
if (mBaseURL && !aNewSpec.IsEmpty()) {
|
||||
nsString empty;
|
||||
nsresult rv;
|
||||
|
|
|
@ -175,7 +175,7 @@ nsImageFrame::Init(nsIPresContext* aPresContext,
|
|||
}
|
||||
}
|
||||
|
||||
if (NS_CONTENT_ATTR_HAS_VALUE == lowSrcResult && lowSrc.Length() > 0) {
|
||||
if (NS_CONTENT_ATTR_HAS_VALUE == lowSrcResult && lowSrc.Length() > 0) {
|
||||
mLowSrcImageLoader = new nsHTMLImageLoader;
|
||||
if (mLowSrcImageLoader != nsnull) {
|
||||
mLowSrcImageLoader->Init(this, UpdateImageFrame, (void*)mLowSrcImageLoader, baseURL, lowSrc);
|
||||
|
@ -359,6 +359,13 @@ nsImageFrame::Reflow(nsIPresContext* aPresContext,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsImageFrame::CanContinueTextRun(PRBool& aContinueTextRun) const
|
||||
{
|
||||
aContinueTextRun = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Computes the width of the specified string. aMaxWidth specifies the maximum
|
||||
// width available. Once this limit is reached no more characters are measured.
|
||||
// The number of characters that fit within the maximum width are returned in
|
||||
|
|
|
@ -1807,6 +1807,7 @@ nsGenericHTMLElement::GetBaseURL(const nsHTMLValue& aBaseHref,
|
|||
if (eHTMLUnit_String == aBaseHref.GetUnit()) {
|
||||
nsAutoString baseHref;
|
||||
aBaseHref.GetStringValue(baseHref);
|
||||
baseHref.Trim(" \t\n\r");
|
||||
|
||||
nsIURI* url = nsnull;
|
||||
{
|
||||
|
|
|
@ -668,6 +668,9 @@ nsHTMLAnchorElement::GetHrefCString(char* &aBuf)
|
|||
|
||||
if (NS_CONTENT_ATTR_HAS_VALUE ==
|
||||
mInner.GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::href, relURLSpec)) {
|
||||
// Clean up any leading or trailing whitespace
|
||||
relURLSpec.Trim(" \t\n\r");
|
||||
|
||||
// Get base URL.
|
||||
nsCOMPtr<nsIURI> baseURL;
|
||||
mInner.GetBaseURL(*getter_AddRefs(baseURL));
|
||||
|
|
|
@ -511,6 +511,9 @@ nsHTMLAreaElement::GetHrefCString(char* &aBuf)
|
|||
|
||||
if (NS_CONTENT_ATTR_HAS_VALUE ==
|
||||
mInner.GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::href, relURLSpec)) {
|
||||
// Clean up any leading or trailing whitespace
|
||||
relURLSpec.Trim(" \t\n\r");
|
||||
|
||||
// Get base URL.
|
||||
nsCOMPtr<nsIURI> baseURL;
|
||||
mInner.GetBaseURL(*getter_AddRefs(baseURL));
|
||||
|
|
|
@ -688,6 +688,7 @@ nsHTMLImageElement::SetProperty(JSContext *aContext, JSObject *aObj, jsval aID,
|
|||
JSString *jsstring;
|
||||
if ((jsstring = JS_ValueToString(aContext, *aVp)) != nsnull) {
|
||||
src.Assign(NS_REINTERPRET_CAST(const PRUnichar*, JS_GetStringChars(jsstring)));
|
||||
src.Trim(" \t\n\r");
|
||||
}
|
||||
else {
|
||||
src.Truncate();
|
||||
|
@ -834,6 +835,7 @@ nsHTMLImageElement::GetSrc(nsAWritableString& aSrc)
|
|||
|
||||
// Get href= attribute (relative URL).
|
||||
mInner.GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::src, relURLSpec);
|
||||
relURLSpec.Trim(" \t\n\r");
|
||||
|
||||
if (nsnull != baseURL && relURLSpec.Length() > 0) {
|
||||
// Get absolute URL.
|
||||
|
|
|
@ -353,6 +353,9 @@ nsHTMLLinkElement::GetHrefCString(char* &aBuf)
|
|||
|
||||
if (NS_CONTENT_ATTR_HAS_VALUE ==
|
||||
mInner.GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::href, relURLSpec)) {
|
||||
// Clean up any leading or trailing whitespace
|
||||
relURLSpec.Trim(" \t\n\r");
|
||||
|
||||
// Get base URL.
|
||||
nsCOMPtr<nsIURI> baseURL;
|
||||
mInner.GetBaseURL(*getter_AddRefs(baseURL));
|
||||
|
|
Загрузка…
Ссылка в новой задаче