summaryrefslogtreecommitdiffstats
path: root/Source/WebCore
diff options
context:
space:
mode:
authorSteve Block <steveblock@google.com>2012-03-27 18:38:35 +0100
committerSteve Block <steveblock@google.com>2012-03-28 16:49:16 +0100
commitc57e584da242d96ba18578a71f4634adc9d1fff6 (patch)
tree745a4f9fa89d7517b3cb1c09b021cf1f9ccf2889 /Source/WebCore
parent6ed1fdfa7999878a811b09cdd647fbeace4353b8 (diff)
downloadexternal_webkit-c57e584da242d96ba18578a71f4634adc9d1fff6.zip
external_webkit-c57e584da242d96ba18578a71f4634adc9d1fff6.tar.gz
external_webkit-c57e584da242d96ba18578a71f4634adc9d1fff6.tar.bz2
Cherry-pick WebKit change r94132 to fix default port in URLs
This is to make sure URL parsing behaviour is up-to-date prior to fixing window.location. See bug for details. Note that a manual edit to HTMLAnchorElement::port() was required to avoid the use of emptyString(). See http://trac.webkit.org/changeset/94132 Bug: 2159848 Change-Id: I13ef58e18df46c1d4592c102d4eb80f54ae53020
Diffstat (limited to 'Source/WebCore')
-rw-r--r--Source/WebCore/html/HTMLAnchorElement.cpp5
-rw-r--r--Source/WebCore/page/Location.cpp6
-rw-r--r--Source/WebCore/platform/KURLGoogle.cpp14
3 files changed, 12 insertions, 13 deletions
diff --git a/Source/WebCore/html/HTMLAnchorElement.cpp b/Source/WebCore/html/HTMLAnchorElement.cpp
index 4636f20..b05e7f5 100644
--- a/Source/WebCore/html/HTMLAnchorElement.cpp
+++ b/Source/WebCore/html/HTMLAnchorElement.cpp
@@ -405,7 +405,10 @@ void HTMLAnchorElement::setPathname(const String& value)
String HTMLAnchorElement::port() const
{
- return String::number(href().port());
+ if (href().hasPort())
+ return String::number(href().port());
+
+ return "";
}
void HTMLAnchorElement::setPort(const String& value)
diff --git a/Source/WebCore/page/Location.cpp b/Source/WebCore/page/Location.cpp
index 5af48cf..9528437 100644
--- a/Source/WebCore/page/Location.cpp
+++ b/Source/WebCore/page/Location.cpp
@@ -84,7 +84,7 @@ String Location::host() const
// Note: this is the IE spec. The NS spec swaps the two, it says
// "The hostname property is the concatenation of the host and port properties, separated by a colon."
const KURL& url = this->url();
- return url.port() ? url.host() + ":" + String::number(url.port()) : url.host();
+ return url.hasPort() ? url.host() + ":" + String::number(url.port()) : url.host();
}
String Location::hostname() const
@@ -101,7 +101,7 @@ String Location::port() const
return String();
const KURL& url = this->url();
- return url.port() ? String::number(url.port()) : "";
+ return url.hasPort() ? String::number(url.port()) : "";
}
String Location::pathname() const
@@ -201,7 +201,7 @@ void Location::setPort(const String& portString, DOMWindow* activeWindow, DOMWin
return;
KURL url = m_frame->document()->url();
int port = portString.toInt();
- if (port < 0 || port > 0xFFFF)
+ if (port < 0 || port > 0xFFFF || portString.isEmpty())
url.removePort();
else
url.setPort(port);
diff --git a/Source/WebCore/platform/KURLGoogle.cpp b/Source/WebCore/platform/KURLGoogle.cpp
index 370862f..7bb1d53 100644
--- a/Source/WebCore/platform/KURLGoogle.cpp
+++ b/Source/WebCore/platform/KURLGoogle.cpp
@@ -670,16 +670,12 @@ void KURL::setPort(unsigned short i)
{
KURLGooglePrivate::Replacements replacements;
String portStr;
- if (i) {
- portStr = String::number(i);
- replacements.SetPort(
- reinterpret_cast<const url_parse::UTF16Char*>(portStr.characters()),
- url_parse::Component(0, portStr.length()));
- } else {
- // Clear any existing port when it is set to 0.
- replacements.ClearPort();
- }
+ portStr = String::number(i);
+ replacements.SetPort(
+ reinterpret_cast<const url_parse::UTF16Char*>(portStr.characters()),
+ url_parse::Component(0, portStr.length()));
+
m_url.replaceComponents(replacements);
}