Bug 1421214 - Try GoToAnchor() with unescaped string before using document's charset. r=smaug

This commit is contained in:
Alphan Chen
2018-01-05 15:12:16 +08:00
parent 6c2da87800
commit 27bc5fb7f8
3 changed files with 32 additions and 6 deletions

View File

@@ -11359,6 +11359,20 @@ nsDocShell::ScrollToAnchor(bool aCurHasRef, bool aNewHasRef,
nsIPresShell::SCROLL_SMOOTH_AUTO);
}
if (NS_FAILED(rv)) {
char* str = ToNewCString(aNewHash);
if (!str) {
return NS_ERROR_OUT_OF_MEMORY;
}
nsUnescape(str);
NS_ConvertUTF8toUTF16 utf16Str(str);
if (!utf16Str.IsEmpty()) {
rv = shell->GoToAnchor(utf16Str, scroll,
nsIPresShell::SCROLL_SMOOTH_AUTO);
}
free(str);
}
// Above will fail if the anchor name is not UTF-8. Need to
// convert from document charset to unicode.
if (NS_FAILED(rv)) {