From kde-commits Sun Nov 30 20:40:36 2014 From: Andrea Iacovitti Date: Sun, 30 Nov 2014 20:40:36 +0000 To: kde-commits Subject: [kdelibs/KDE/4.14] khtml: Fix setting unencoded url fragment id Message-Id: X-MARC-Message: https://marc.info/?l=kde-commits&m=141738004610861 Git commit c80098c40cb520da9ac5715603fef77d969c9971 by Andrea Iacovitti. Committed on 30/11/2014 at 20:37. Pushed by aiacovitti into branch 'KDE/4.14'. Fix setting unencoded url fragment id BUG: 303618 M +2 -2 khtml/ecma/kjs_window.cpp M +12 -0 khtml/xml/dom_docimpl.cpp http://commits.kde.org/kdelibs/c80098c40cb520da9ac5715603fef77d969c9971 diff --git a/khtml/ecma/kjs_window.cpp b/khtml/ecma/kjs_window.cpp index bd83222..d9b26f7 100644 --- a/khtml/ecma/kjs_window.cpp +++ b/khtml/ecma/kjs_window.cpp @@ -2947,12 +2947,12 @@ void Location::put(ExecState *exec, const Identifie= r &p, JSValue *v, int attr) // Note that we want to do gotoAnchor even when the hash is already = set, so we // scroll the destination into view. = - // Setting this must always provide a ref, even if just ; see + // Setting this must always provide a ref, even if just # see // HTML5 2.6. if (str.isEmpty()) { url.setHTMLRef(""); } else { - url.setRef(str); + url.setHTMLRef(KUrl::fromPercentEncoding(str.toUtf8())); } break; case Host: { diff --git a/khtml/xml/dom_docimpl.cpp b/khtml/xml/dom_docimpl.cpp index b8e5910..0453e1b 100644 --- a/khtml/xml/dom_docimpl.cpp +++ b/khtml/xml/dom_docimpl.cpp @@ -1696,6 +1696,18 @@ void DocumentImpl::finishParsing ( ) = QString DocumentImpl::completeURL(const QString& url) const { + if (url.startsWith(QLatin1Char('#'))) { + const QString ref =3D KUrl::fromPercentEncoding(url.mid(1).toUtf8(= )); + KUrl u =3D baseURL(); + if (ref.isEmpty()) { + u.setHTMLRef(""); + } + else { + u.setHTMLRef(ref); + } + return u.url(); + } + return KUrl(baseURL(),url /*,m_decoderMibEnum*/).url(); } =20