Bug 1527236 - Allow % in URLs for Thunderbird. r=valentin
authorJorg K <jorgk@jorgk.com>
Tue, 12 Feb 2019 18:43:30 +0100
changeset 458718 aa39bdeb511f
parent 458717 e8f7092b8d5d
child 458719 5f58b05d9d29
push id35546
push userrmaries@mozilla.com
push dateWed, 13 Feb 2019 04:27:59 +0000
treeherdermozilla-central@636d2c00234d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvalentin
bugs1527236
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1527236 - Allow % in URLs for Thunderbird. r=valentin
netwerk/base/nsStandardURL.cpp
netwerk/test/unit/test_standardurl.js
netwerk/test/unit/xpcshell.ini
--- a/netwerk/base/nsStandardURL.cpp
+++ b/netwerk/base/nsStandardURL.cpp
@@ -64,17 +64,22 @@ bool nsStandardURL::gPunycodeHost = true
 // so we do not need to "optimize" TestForInvalidHostCharacters.
 //
 constexpr bool TestForInvalidHostCharacters(char c) {
   // Testing for these:
   // CONTROL_CHARACTERS " #/:?@[\\]*<>|\"";
   return (c > 0 && c < 32) ||  // The control characters are [1, 31]
          c == ' ' || c == '#' || c == '/' || c == ':' || c == '?' || c == '@' ||
          c == '[' || c == '\\' || c == ']' || c == '*' || c == '<' ||
+#if defined(MOZ_THUNDERBIRD) || defined(MOZ_SUITE)
+         // Mailnews %-escapes file paths into URLs.
+         c == '>' || c == '|' || c == '"';
+#else
          c == '>' || c == '|' || c == '"' || c == '%';
+#endif
 }
 constexpr ASCIIMaskArray sInvalidHostChars =
     CreateASCIIMask(TestForInvalidHostCharacters);
 
 //----------------------------------------------------------------------------
 // nsStandardURL::nsSegmentEncoder
 //----------------------------------------------------------------------------
 
--- a/netwerk/test/unit/test_standardurl.js
+++ b/netwerk/test/unit/test_standardurl.js
@@ -1,11 +1,12 @@
 "use strict";
 
-ChromeUtils.import('resource://gre/modules/Services.jsm');
+var {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
+var {AppConstants} = ChromeUtils.import("resource://gre/modules/AppConstants.jsm");
 const gPrefs = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch);
 
 function symmetricEquality(expect, a, b)
 {
   /* Use if/else instead of |do_check_eq(expect, a.spec == b.spec)| so
      that we get the specs output on the console if the check fails.
    */
   if (expect) {
@@ -303,17 +304,18 @@ add_test(function test_accentEncoding()
   Assert.equal(url.query, "hello=`");
 
   url = stringToURL("http://example.com/?hello=%2C");
   Assert.equal(url.spec, "http://example.com/?hello=%2C");
   Assert.equal(url.query, "hello=%2C");
   run_next_test();
 });
 
-add_test(function test_percentDecoding()
+add_test({ skip_if: () => AppConstants.MOZ_APP_NAME == "thunderbird" },
+         function test_percentDecoding()
 {
   var url = stringToURL("http://%70%61%73%74%65%62%69%6E.com");
   Assert.equal(url.spec, "http://pastebin.com/");
 
   // Disallowed hostname characters are rejected even when percent encoded
   Assert.throws(() => { url = stringToURL("http://example.com%0a%23.google.com/"); },
                 /NS_ERROR_MALFORMED_URI/, "invalid characters are not allowed");
   run_next_test();
@@ -693,17 +695,18 @@ add_test(function test_idna_host() {
 
   url = stringToURL("http://user:password@www.ält.com:8080/path?query#etc");
   url = url.mutate().setRef("").finalize();
   equal(url.spec, "http://user:password@www.xn--lt-uia.com:8080/path?query");
 
   run_next_test();
 });
 
-add_test(function test_bug1517025() {
+add_test({ skip_if: () => AppConstants.MOZ_APP_NAME == "thunderbird" },
+         function test_bug1517025() {
   Assert.throws(() => { let other = stringToURL("https://b%9a/"); },
                 /NS_ERROR_UNEXPECTED/, "bad URI");
 
   Assert.throws(() => { let other = stringToURL("https://b%9ª/"); },
                 /NS_ERROR_MALFORMED_URI/, "bad URI");
 
   let base = stringToURL("https://bug1517025.bmoattachments.org/attachment.cgi?id=9033787");
   Assert.throws(() => { let uri = Services.io.newURI("/\\b%9ª", "windows-1252", base); },
--- a/netwerk/test/unit/xpcshell.ini
+++ b/netwerk/test/unit/xpcshell.ini
@@ -377,17 +377,19 @@ skip-if = os == "android"
 [test_suspend_channel_on_modified.js]
 [test_inhibit_caching.js]
 [test_dns_disable_ipv4.js]
 [test_dns_disable_ipv6.js]
 [test_bug1195415.js]
 [test_cookie_blacklist.js]
 [test_getHost.js]
 [test_bug412457.js]
+skip-if = appname == "thunderbird"
 [test_bug464591.js]
+skip-if = appname == "thunderbird"
 [test_alt-data_simple.js]
 [test_alt-data_stream.js]
 [test_alt-data_too_big.js]
 [test_alt-data_overwrite.js]
 [test_cache-control_request.js]
 [test_bug1279246.js]
 [test_throttlequeue.js]
 [test_throttlechannel.js]