Commit f55fe75a authored by mitz@apple.com's avatar mitz@apple.com

WebCore:

        Reviewed by Darin Adler.

        - fix http://bugs.webkit.org/show_bug.cgi?id=17676
          <rdar://problem/5781091> REGRESSION (r30240-r30267): href attribute values with non-ASCII characters in the host part do not work

        Test: fast/encoding/url-host-name-non-ascii.html

        * platform/KURL.cpp:
        (WebCore::appendEncodedHostname): Added an early return in the all-ASCII
        case to avoid copying the host name twice and corrected the error
        checking after calling uidna_IDNToASCII().

LayoutTests:

        - test for http://bugs.webkit.org/show_bug.cgi?id=17676
          <rdar://problem/5781091> REGRESSION (r30240-r30267): href attribute values with non-ASCII characters in the host part do not work

        * fast/encoding/url-host-name-non-ascii-expected.txt: Added.
        * fast/encoding/url-host-name-non-ascii.html: Added.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@30781 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent f29c463e
2008-03-04 Dan Bernstein <mitz@apple.com>
- test for http://bugs.webkit.org/show_bug.cgi?id=17676
<rdar://problem/5781091> REGRESSION (r30240-r30267): href attribute values with non-ASCII characters in the host part do not work
* fast/encoding/url-host-name-non-ascii-expected.txt: Added.
* fast/encoding/url-host-name-non-ascii.html: Added.
2008-03-04 Nikolas Zimmermann <zimmermann@kde.org> 2008-03-04 Nikolas Zimmermann <zimmermann@kde.org>
Reviewed by Eric. Reviewed by Eric.
Test for http://bugs.webkit.org/show_bug.cgi?id=17676 REGRESSION (r30240-r30267): href attribute values with non-ASCII characters in the host part do not work.
PASS
<p>
Test for <i><a href="http://bugs.webkit.org/show_bug.cgi?id=17676">http://bugs.webkit.org/show_bug.cgi?id=17676</a>
REGRESSION (r30240-r30267): href attribute values with non-ASCII characters in the host part do not work</i>.
</p>
<a id="anchor" href="http://w&#xe9;bkit.org/"></a>
<div id="result"></div>
<script>
if (window.layoutTestController)
layoutTestController.dumpAsText();
var encodedURL = document.getElementById("anchor").href;
document.getElementById("result").innerText = encodedURL == "http://xn--wbkit-bsa.org/" ? "PASS" : "FAIL: The encoded URL was '" + encodedURL + "'.";
</script>
2008-03-04 Dan Bernstein <mitz@apple.com>
Reviewed by Darin Adler.
- fix http://bugs.webkit.org/show_bug.cgi?id=17676
<rdar://problem/5781091> REGRESSION (r30240-r30267): href attribute values with non-ASCII characters in the host part do not work
Test: fast/encoding/url-host-name-non-ascii.html
* platform/KURL.cpp:
(WebCore::appendEncodedHostname): Added an early return in the all-ASCII
case to avoid copying the host name twice and corrected the error
checking after calling uidna_IDNToASCII().
2008-03-04 Sam Weinig <sam@webkit.org> 2008-03-04 Sam Weinig <sam@webkit.org>
Reviewed by Dan Bernstein. Reviewed by Dan Bernstein.
...@@ -1324,15 +1324,17 @@ static void appendEncodedHostname(UCharBuffer& buffer, const UChar* str, unsigne ...@@ -1324,15 +1324,17 @@ static void appendEncodedHostname(UCharBuffer& buffer, const UChar* str, unsigne
// For host names bigger than this, we won't do IDN encoding, which is almost certainly OK. // For host names bigger than this, we won't do IDN encoding, which is almost certainly OK.
const unsigned hostnameBufferLength = 2048; const unsigned hostnameBufferLength = 2048;
if (strLen > hostnameBufferLength || charactersAreAllASCII(str, strLen)) if (strLen > hostnameBufferLength || charactersAreAllASCII(str, strLen)) {
buffer.append(str, strLen); buffer.append(str, strLen);
return;
}
#if USE(ICU_UNICODE) #if USE(ICU_UNICODE)
UChar hostnameBuffer[hostnameBufferLength]; UChar hostnameBuffer[hostnameBufferLength];
UErrorCode error = U_ZERO_ERROR; UErrorCode error = U_ZERO_ERROR;
int32_t numCharactersConverted = uidna_IDNToASCII(str, strLen, hostnameBuffer, int32_t numCharactersConverted = uidna_IDNToASCII(str, strLen, hostnameBuffer,
hostnameBufferLength, UIDNA_ALLOW_UNASSIGNED, 0, &error); hostnameBufferLength, UIDNA_ALLOW_UNASSIGNED, 0, &error);
if (error != U_ZERO_ERROR) if (error == U_ZERO_ERROR)
buffer.append(hostnameBuffer, numCharactersConverted); buffer.append(hostnameBuffer, numCharactersConverted);
#elif USE(QT4_UNICODE) #elif USE(QT4_UNICODE)
QByteArray result = QUrl::toAce(String(str, strLen)); QByteArray result = QUrl::toAce(String(str, strLen));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment