+2008-01-12 Maciej Stachowiak <mjs@apple.com>
+
+ Reviewed by Sam.
+
+ - fixed <rdar://problem/5556374> REGRESSION: cross-domain error when one URL uses an explicit port number and another doesn't
+
+ * platform/SecurityOrigin.cpp:
+ (WebCore::isDefaultPortForProtocol):
+ (WebCore::SecurityOrigin::SecurityOrigin):
+
2008-01-11 Geoffrey Garen <ggaren@apple.com>
Reviewed by Oliver Hunt.
namespace WebCore {
+static bool isDefaultPortForProtocol(unsigned short port, String protocol)
+{
+ if (protocol.isEmpty())
+ return false;
+
+ static HashMap<String, unsigned> defaultPorts;
+ if (defaultPorts.isEmpty()) {
+ defaultPorts.set("http", 80);
+ defaultPorts.set("https", 443);
+ defaultPorts.set("ftp", 21);
+ defaultPorts.set("ftps", 990);
+ }
+ return defaultPorts.get(protocol) == port;
+}
+
SecurityOrigin::SecurityOrigin(const String& protocol, const String& host, unsigned short port)
: m_protocol(protocol.lower())
, m_host(host.lower())
// data: URLs are not allowed access to anything other than themselves.
if (m_protocol == "data")
m_noAccess = true;
+
+
+ if (isDefaultPortForProtocol(m_port, m_protocol)) {
+ m_port = 0;
+ m_portSet = false;
+ }
}
bool SecurityOrigin::isEmpty() const