[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [tor-browser/tor-browser-68.1.0esr-9.0-2] Bug 1560574 - use FormatPRExplodedTime to display GMT; r=kershaw
commit a2e76dee549c9efb60bfa13c0e6e4e5f8b5edd76
Author: Liang-Heng Chen <xeonchen@xxxxxxxxx>
Date: Tue Aug 20 14:00:31 2019 +0000
Bug 1560574 - use FormatPRExplodedTime to display GMT; r=kershaw
Differential Revision: https://phabricator.services.mozilla.com/D36502
--HG--
extra : moz-landing-system : lando
---
.../streamconv/converters/nsFTPDirListingConv.cpp | 2 +-
netwerk/streamconv/converters/nsIndexedToHTML.cpp | 25 +++++++++++---
netwerk/test/unit/test_bug365133.js | 16 ++++-----
netwerk/test/unit/test_bug484684.js | 40 +++++++++++-----------
netwerk/test/unit/test_bug515583.js | 4 +--
netwerk/test/unit/test_bug543805.js | 24 ++++++-------
6 files changed, 64 insertions(+), 47 deletions(-)
diff --git a/netwerk/streamconv/converters/nsFTPDirListingConv.cpp b/netwerk/streamconv/converters/nsFTPDirListingConv.cpp
index af0093fd5c6c..b721016afd8f 100644
--- a/netwerk/streamconv/converters/nsFTPDirListingConv.cpp
+++ b/netwerk/streamconv/converters/nsFTPDirListingConv.cpp
@@ -294,7 +294,7 @@ char* nsFTPDirListingConv::DigestBufferLines(char* aBuffer,
// the application/http-index-format specs
// viewers of such a format can then reformat this into the
// current locale (or anything else they choose)
- PR_FormatTimeUSEnglish(buffer, sizeof(buffer), "%a, %d %b %Y %H:%M:%S",
+ PR_FormatTimeUSEnglish(buffer, sizeof(buffer), "%a, %d %b %Y %H:%M:%S GMT",
&result.fe_time);
nsAutoCString escaped;
diff --git a/netwerk/streamconv/converters/nsIndexedToHTML.cpp b/netwerk/streamconv/converters/nsIndexedToHTML.cpp
index cb8cf9c2f065..9ff8985cd48a 100644
--- a/netwerk/streamconv/converters/nsIndexedToHTML.cpp
+++ b/netwerk/streamconv/converters/nsIndexedToHTML.cpp
@@ -25,6 +25,7 @@
#include "nsDirIndexParser.h"
#include "nsNativeCharsetUtils.h"
#include "nsString.h"
+#include "nsContentUtils.h"
#include <algorithm>
#include "nsIChannel.h"
#include "mozilla/Unused.h"
@@ -670,6 +671,24 @@ nsIndexedToHTML::OnDataAvailable(nsIRequest* aRequest, nsIInputStream* aInput,
return mParser->OnDataAvailable(aRequest, aInput, aOffset, aCount);
}
+static nsresult FormatTime(const nsDateFormatSelector aDateFormatSelector,
+ const nsTimeFormatSelector aTimeFormatSelector,
+ const PRTime aPrTime, nsAString& aStringOut) {
+ // FormatPRExplodedTime will use GMT based formatted string (e.g. GMT+1)
+ // instead of local time zone name (e.g. CEST).
+ // To avoid this case when ResistFingerprinting is disabled, use
+ // |FormatPRTime| to show exact time zone name.
+ if (!nsContentUtils::ShouldResistFingerprinting()) {
+ return mozilla::DateTimeFormat::FormatPRTime(
+ aDateFormatSelector, aTimeFormatSelector, aPrTime, aStringOut);
+ }
+
+ PRExplodedTime prExplodedTime;
+ PR_ExplodeTime(aPrTime, PR_GMTParameters, &prExplodedTime);
+ return mozilla::DateTimeFormat::FormatPRExplodedTime(
+ aDateFormatSelector, aTimeFormatSelector, &prExplodedTime, aStringOut);
+}
+
NS_IMETHODIMP
nsIndexedToHTML::OnIndexAvailable(nsIRequest* aRequest, nsISupports* aCtxt,
nsIDirIndex* aIndex) {
@@ -816,12 +835,10 @@ nsIndexedToHTML::OnIndexAvailable(nsIRequest* aRequest, nsISupports* aCtxt,
pushBuffer.AppendInt(static_cast<int64_t>(t));
pushBuffer.AppendLiteral("\">");
nsAutoString formatted;
- mozilla::DateTimeFormat::FormatPRTime(kDateFormatShort, kTimeFormatNone, t,
- formatted);
+ FormatTime(kDateFormatShort, kTimeFormatNone, t, formatted);
AppendNonAsciiToNCR(formatted, pushBuffer);
pushBuffer.AppendLiteral("</td>\n <td>");
- mozilla::DateTimeFormat::FormatPRTime(kDateFormatNone, kTimeFormatSeconds,
- t, formatted);
+ FormatTime(kDateFormatNone, kTimeFormatSeconds, t, formatted);
// use NCR to show date in any doc charset
AppendNonAsciiToNCR(formatted, pushBuffer);
}
diff --git a/netwerk/test/unit/test_bug365133.js b/netwerk/test/unit/test_bug365133.js
index d9aabd5c6ea9..a872d7a5c7d9 100644
--- a/netwerk/test/unit/test_bug365133.js
+++ b/netwerk/test/unit/test_bug365133.js
@@ -8,7 +8,7 @@ const tests = [
URL +
"\n" +
"200: filename content-length last-modified file-type\n" +
- '201: "a%20" 0 Sat%2C%2001%20Jan%202000%2000%3A00%3A00 DIRECTORY \n',
+ '201: "a%20" 0 Sat%2C%2001%20Jan%202000%2000%3A00%3A00%20GMT DIRECTORY \n',
],
[
/* Unix style listing, space at the end of link name */
@@ -17,7 +17,7 @@ const tests = [
URL +
"\n" +
"200: filename content-length last-modified file-type\n" +
- '201: "l%20" 2 Sat%2C%2001%20Jan%202000%2000%3A00%3A00 SYMBOLIC-LINK \n',
+ '201: "l%20" 2 Sat%2C%2001%20Jan%202000%2000%3A00%3A00%20GMT SYMBOLIC-LINK \n',
],
[
/* Unix style listing, regular file with " -> " in name */
@@ -26,7 +26,7 @@ const tests = [
URL +
"\n" +
"200: filename content-length last-modified file-type\n" +
- '201: "arrow%20-%3E%20in%20name%20" 0 Sat%2C%2001%20Jan%202000%2000%3A00%3A00 FILE \n',
+ '201: "arrow%20-%3E%20in%20name%20" 0 Sat%2C%2001%20Jan%202000%2000%3A00%3A00%20GMT FILE \n',
],
[
/* Unix style listing, tab at the end of filename */
@@ -35,7 +35,7 @@ const tests = [
URL +
"\n" +
"200: filename content-length last-modified file-type\n" +
- '201: "t%09" 0 Sat%2C%2001%20Jan%202000%2000%3A00%3A00 DIRECTORY \n',
+ '201: "t%09" 0 Sat%2C%2001%20Jan%202000%2000%3A00%3A00%20GMT DIRECTORY \n',
],
[
/* Unix style listing, multiple " -> " in filename */
@@ -44,7 +44,7 @@ const tests = [
URL +
"\n" +
"200: filename content-length last-modified file-type\n" +
- '201: "symlink%20with%20arrow%20-%3E%20in%20name" 26 Sat%2C%2001%20Jan%202000%2000%3A00%3A00 SYMBOLIC-LINK \n',
+ '201: "symlink%20with%20arrow%20-%3E%20in%20name" 26 Sat%2C%2001%20Jan%202000%2000%3A00%3A00%20GMT SYMBOLIC-LINK \n',
],
[
/* Unix style listing, multiple " -> " in filename, incorrect filesize */
@@ -53,7 +53,7 @@ const tests = [
URL +
"\n" +
"200: filename content-length last-modified file-type\n" +
- '201: "symlink%20with%20arrow%20-%3E%20in%20name%20-%3E%20file%20with%20arrow" 0 Sat%2C%2001%20Jan%202000%2000%3A00%3A00 SYMBOLIC-LINK \n',
+ '201: "symlink%20with%20arrow%20-%3E%20in%20name%20-%3E%20file%20with%20arrow" 0 Sat%2C%2001%20Jan%202000%2000%3A00%3A00%20GMT SYMBOLIC-LINK \n',
],
[
/* DOS style listing, space at the end of filename, year 1999 */
@@ -62,7 +62,7 @@ const tests = [
URL +
"\n" +
"200: filename content-length last-modified file-type\n" +
- '201: "file%20" 1024 Fri%2C%2001%20Jan%201999%2001%3A00%3A00 FILE \n',
+ '201: "file%20" 1024 Fri%2C%2001%20Jan%201999%2001%3A00%3A00%20GMT FILE \n',
],
[
/* DOS style listing, tab at the end of filename, year 2000 */
@@ -71,7 +71,7 @@ const tests = [
URL +
"\n" +
"200: filename content-length last-modified file-type\n" +
- '201: "file%09" 1024 Sat%2C%2001%20Jan%202000%2001%3A00%3A00 FILE \n',
+ '201: "file%09" 1024 Sat%2C%2001%20Jan%202000%2001%3A00%3A00%20GMT FILE \n',
],
];
diff --git a/netwerk/test/unit/test_bug484684.js b/netwerk/test/unit/test_bug484684.js
index ae0d8276aaa4..e867d0c01637 100644
--- a/netwerk/test/unit/test_bug484684.js
+++ b/netwerk/test/unit/test_bug484684.js
@@ -10,8 +10,8 @@ const tests = [
URL +
"\n" +
"200: filename content-length last-modified file-type\n" +
- '201: "file1" 0 Sat%2C%2001%20Jan%202000%2000%3A00%3A00 FILE \n' +
- '201: "%20file2" 0 Sat%2C%2001%20Jan%202000%2000%3A00%3A00 FILE \n',
+ '201: "file1" 0 Sat%2C%2001%20Jan%202000%2000%3A00%3A00%20GMT FILE \n' +
+ '201: "%20file2" 0 Sat%2C%2001%20Jan%202000%2000%3A00%3A00%20GMT FILE \n',
],
// old Hellsoft unix format
[
@@ -22,8 +22,8 @@ const tests = [
URL +
"\n" +
"200: filename content-length last-modified file-type\n" +
- '201: "file1" 214059 Sat%2C%2001%20Jan%202000%2000%3A00%3A00 FILE \n' +
- '201: "file2" 214059 Sat%2C%2001%20Jan%202000%2000%3A00%3A00 FILE \n',
+ '201: "file1" 214059 Sat%2C%2001%20Jan%202000%2000%3A00%3A00%20GMT FILE \n' +
+ '201: "file2" 214059 Sat%2C%2001%20Jan%202000%2000%3A00%3A00%20GMT FILE \n',
],
// new Hellsoft unix format
[
@@ -34,8 +34,8 @@ const tests = [
URL +
"\n" +
"200: filename content-length last-modified file-type\n" +
- '201: "file1" 192 Sat%2C%2001%20Jan%202000%2000%3A00%3A00 FILE \n' +
- '201: "%20file2" 192 Sat%2C%2001%20Jan%202000%2000%3A00%3A00 FILE \n',
+ '201: "file1" 192 Sat%2C%2001%20Jan%202000%2000%3A00%3A00%20GMT FILE \n' +
+ '201: "%20file2" 192 Sat%2C%2001%20Jan%202000%2000%3A00%3A00%20GMT FILE \n',
],
// DOS format with correct offsets
[
@@ -50,12 +50,12 @@ const tests = [
URL +
"\n" +
"200: filename content-length last-modified file-type\n" +
- '201: "dir1" 0 Sat%2C%2001%20Jan%202000%2001%3A00%3A00 DIRECTORY \n' +
- '201: "junction1" Sat%2C%2001%20Jan%202000%2001%3A00%3A00 SYMBOLIC-LINK \n' +
- '201: "file1" 95077 Sat%2C%2001%20Jan%202000%2001%3A00%3A00 FILE \n' +
- '201: "%20dir2" 0 Sat%2C%2001%20Jan%202000%2001%3A00%3A00 DIRECTORY \n' +
- '201: "%20junction2" Sat%2C%2001%20Jan%202000%2001%3A00%3A00 SYMBOLIC-LINK \n' +
- '201: "%20file2" 95077 Sat%2C%2001%20Jan%202000%2001%3A00%3A00 FILE \n',
+ '201: "dir1" 0 Sat%2C%2001%20Jan%202000%2001%3A00%3A00%20GMT DIRECTORY \n' +
+ '201: "junction1" Sat%2C%2001%20Jan%202000%2001%3A00%3A00%20GMT SYMBOLIC-LINK \n' +
+ '201: "file1" 95077 Sat%2C%2001%20Jan%202000%2001%3A00%3A00%20GMT FILE \n' +
+ '201: "%20dir2" 0 Sat%2C%2001%20Jan%202000%2001%3A00%3A00%20GMT DIRECTORY \n' +
+ '201: "%20junction2" Sat%2C%2001%20Jan%202000%2001%3A00%3A00%20GMT SYMBOLIC-LINK \n' +
+ '201: "%20file2" 95077 Sat%2C%2001%20Jan%202000%2001%3A00%3A00%20GMT FILE \n',
],
// DOS format with wrong offsets
[
@@ -72,14 +72,14 @@ const tests = [
URL +
"\n" +
"200: filename content-length last-modified file-type\n" +
- '201: "dir1" 0 Sat%2C%2001%20Jan%202000%2001%3A00%3A00 DIRECTORY \n' +
- '201: "dir2" 0 Sat%2C%2001%20Jan%202000%2001%3A00%3A00 DIRECTORY \n' +
- '201: "dir3" 0 Sat%2C%2001%20Jan%202000%2001%3A00%3A00 DIRECTORY \n' +
- '201: "junction1" Sat%2C%2001%20Jan%202000%2001%3A00%3A00 SYMBOLIC-LINK \n' +
- '201: "junction2" Sat%2C%2001%20Jan%202000%2001%3A00%3A00 SYMBOLIC-LINK \n' +
- '201: "junction3" Sat%2C%2001%20Jan%202000%2001%3A00%3A00 SYMBOLIC-LINK \n' +
- '201: "file1" 95077 Sat%2C%2001%20Jan%202000%2001%3A00%3A00 FILE \n' +
- '201: "file2" 95077 Sat%2C%2001%20Jan%202000%2001%3A00%3A00 FILE \n',
+ '201: "dir1" 0 Sat%2C%2001%20Jan%202000%2001%3A00%3A00%20GMT DIRECTORY \n' +
+ '201: "dir2" 0 Sat%2C%2001%20Jan%202000%2001%3A00%3A00%20GMT DIRECTORY \n' +
+ '201: "dir3" 0 Sat%2C%2001%20Jan%202000%2001%3A00%3A00%20GMT DIRECTORY \n' +
+ '201: "junction1" Sat%2C%2001%20Jan%202000%2001%3A00%3A00%20GMT SYMBOLIC-LINK \n' +
+ '201: "junction2" Sat%2C%2001%20Jan%202000%2001%3A00%3A00%20GMT SYMBOLIC-LINK \n' +
+ '201: "junction3" Sat%2C%2001%20Jan%202000%2001%3A00%3A00%20GMT SYMBOLIC-LINK \n' +
+ '201: "file1" 95077 Sat%2C%2001%20Jan%202000%2001%3A00%3A00%20GMT FILE \n' +
+ '201: "file2" 95077 Sat%2C%2001%20Jan%202000%2001%3A00%3A00%20GMT FILE \n',
],
];
diff --git a/netwerk/test/unit/test_bug515583.js b/netwerk/test/unit/test_bug515583.js
index 85db9fd8e9ef..fe958747e25c 100644
--- a/netwerk/test/unit/test_bug515583.js
+++ b/netwerk/test/unit/test_bug515583.js
@@ -14,8 +14,8 @@ const tests = [
URL +
"\n" +
"200: filename content-length last-modified file-type\n" +
- '201: "A" 2048 Wed%2C%2003%20Mar%201993%2018%3A09%3A01 FILE \n' +
- '201: "E" 2048 Mon%2C%2008%20Mar%201993%2018%3A09%3A01 FILE \n',
+ '201: "A" 2048 Wed%2C%2003%20Mar%201993%2018%3A09%3A01%20GMT FILE \n' +
+ '201: "E" 2048 Mon%2C%2008%20Mar%201993%2018%3A09%3A01%20GMT FILE \n',
],
[
"\r\r\r\n",
diff --git a/netwerk/test/unit/test_bug543805.js b/netwerk/test/unit/test_bug543805.js
index f4dec7e099b4..8ea493982e01 100644
--- a/netwerk/test/unit/test_bug543805.js
+++ b/netwerk/test/unit/test_bug543805.js
@@ -22,24 +22,24 @@ const tests = [
day +
"%2C%2001%20Jan%20" +
year +
- "%2020%3A19%3A00 FILE \n" +
+ "%2020%3A19%3A00%20GMT FILE \n" +
'201: "%20test.blankfile" 22 ' +
day +
"%2C%2001%20Jan%20" +
year +
- "%2020%3A19%3A00 FILE \n" +
- '201: "%20test2.blankfile" 33 Tue%2C%2001%20Apr%202008%2000%3A00%3A00 FILE \n' +
+ "%2020%3A19%3A00%20GMT FILE \n" +
+ '201: "%20test2.blankfile" 33 Tue%2C%2001%20Apr%202008%2000%3A00%3A00%20GMT FILE \n' +
'201: "nodup.file" 44 ' +
day +
"%2C%2001%20Jan%20" +
year +
- "%2020%3A19%3A00 FILE \n" +
+ "%2020%3A19%3A00%20GMT FILE \n" +
'201: "test.file" 55 ' +
day +
"%2C%2001%20Jan%20" +
year +
- "%2020%3A19%3A00 FILE \n" +
- '201: "test2.file" 66 Tue%2C%2001%20Apr%202008%2000%3A00%3A00 FILE \n',
+ "%2020%3A19%3A00%20GMT FILE \n" +
+ '201: "test2.file" 66 Tue%2C%2001%20Apr%202008%2000%3A00%3A00%20GMT FILE \n',
],
// standard ls format
@@ -59,24 +59,24 @@ const tests = [
day +
"%2C%2001%20Jan%20" +
year +
- "%2020%3A19%3A00 FILE \n" +
+ "%2020%3A19%3A00%20GMT FILE \n" +
'201: "%20test.blankfile" 22 ' +
day +
"%2C%2001%20Jan%20" +
year +
- "%2020%3A19%3A00 FILE \n" +
- '201: "%20test2.blankfile" 33 Tue%2C%2001%20Apr%202008%2000%3A00%3A00 FILE \n' +
+ "%2020%3A19%3A00%20GMT FILE \n" +
+ '201: "%20test2.blankfile" 33 Tue%2C%2001%20Apr%202008%2000%3A00%3A00%20GMT FILE \n' +
'201: "nodup.file" 44 ' +
day +
"%2C%2001%20Jan%20" +
year +
- "%2020%3A19%3A00 FILE \n" +
+ "%2020%3A19%3A00%20GMT FILE \n" +
'201: "test.file" 55 ' +
day +
"%2C%2001%20Jan%20" +
year +
- "%2020%3A19%3A00 FILE \n" +
- '201: "test2.file" 66 Tue%2C%2001%20Apr%202008%2000%3A00%3A00 FILE \n',
+ "%2020%3A19%3A00%20GMT FILE \n" +
+ '201: "test2.file" 66 Tue%2C%2001%20Apr%202008%2000%3A00%3A00%20GMT FILE \n',
],
];
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits