diff --git a/dom/src/storage/nsDOMStorage.cpp b/dom/src/storage/nsDOMStorage.cpp index 2425f79701d..8e348cbf93f 100644 --- a/dom/src/storage/nsDOMStorage.cpp +++ b/dom/src/storage/nsDOMStorage.cpp @@ -37,6 +37,7 @@ * * ***** END LICENSE BLOCK ***** */ +#include "prnetdb.h" #include "nsCOMPtr.h" #include "nsDOMError.h" #include "nsDOMClassInfo.h" @@ -1093,6 +1094,15 @@ PRBool nsDOMStorageList::CanAccessDomain(const nsAString& aRequestedDomain, const nsAString& aCurrentDomain) { + PRNetAddr address; + PRStatus status = PR_StringToNetAddr(NS_ConvertUTF16toUTF8(aCurrentDomain).get(), &address); + + if (status == PR_SUCCESS) { + // An IP address must match exactly. IPv6: when location is e.g. "::1" and we require + // "0:0:0:0:0:1" then access will be denied. + return aRequestedDomain == aCurrentDomain; + } + nsStringArray requestedDomainArray, currentDomainArray; PRBool ok = ConvertDomainToArray(aRequestedDomain, &requestedDomainArray); if (!ok) diff --git a/dom/tests/mochitest/bugs/Makefile.in b/dom/tests/mochitest/bugs/Makefile.in index e23b3961bae..bba1c8a2a02 100644 --- a/dom/tests/mochitest/bugs/Makefile.in +++ b/dom/tests/mochitest/bugs/Makefile.in @@ -64,6 +64,8 @@ _TEST_FILES = \ test_bug397571.html \ test_bug400204.html \ test_bug404748.html \ + test_bug409349.html \ + iframe_bug409349.html \ test_bug411103.html \ $(NULL) diff --git a/dom/tests/mochitest/bugs/iframe_bug409349.html b/dom/tests/mochitest/bugs/iframe_bug409349.html new file mode 100644 index 00000000000..2aef169893f --- /dev/null +++ b/dom/tests/mochitest/bugs/iframe_bug409349.html @@ -0,0 +1,63 @@ + + + + Child window at 127.0.0.1 + + + + + diff --git a/dom/tests/mochitest/bugs/test_bug409349.html b/dom/tests/mochitest/bugs/test_bug409349.html new file mode 100644 index 00000000000..032f0055c8b --- /dev/null +++ b/dom/tests/mochitest/bugs/test_bug409349.html @@ -0,0 +1,36 @@ + + + + Cannot get globalStorage objects for partial IP addresses + + + + + +

+ + + + +
+
+
+ +