зеркало из https://github.com/mozilla/gecko-dev.git
Merge inbound to central, a=merge
MozReview-Commit-ID: 56QI5RIvpXC
This commit is contained in:
Коммит
7145ee5d12
2
CLOBBER
2
CLOBBER
|
@ -22,4 +22,4 @@
|
|||
# changes to stick? As of bug 928195, this shouldn't be necessary! Please
|
||||
# don't change CLOBBER for WebIDL changes any more.
|
||||
|
||||
Bug 1309866 moving files from jar.mn to modules left duplicated files on at least Mac static analysis builds
|
||||
Bug 1142403 needs a clobber to force jemalloc to rerun configure.
|
||||
|
|
|
@ -10,6 +10,9 @@ if test "$MOZ_BUILD_APP" != js -o -n "$JS_STANDALONE"; then
|
|||
|
||||
if test -z "$MOZ_SYSTEM_JEMALLOC" -a "$MOZ_MEMORY" && test -n "$MOZ_JEMALLOC4" -o -n "$MOZ_REPLACE_MALLOC"; then
|
||||
ac_configure_args="--build=$build --host=$target --enable-stats --with-jemalloc-prefix=je_ --disable-valgrind"
|
||||
if test -n "$MOZ_DEBUG"; then
|
||||
ac_configure_args="$ac_configure_args --enable-debug"
|
||||
fi
|
||||
# We're using memalign for _aligned_malloc in memory/build/mozmemory_wrap.c
|
||||
# on Windows, so just export memalign on all platforms.
|
||||
ac_configure_args="$ac_configure_args ac_cv_func_memalign=yes"
|
||||
|
|
|
@ -131,8 +131,6 @@
|
|||
#include "nsIParser.h"
|
||||
#include "nsIContentSink.h"
|
||||
|
||||
#include "nsDateTimeFormatCID.h"
|
||||
#include "nsIDateTimeFormat.h"
|
||||
#include "mozilla/EventDispatcher.h"
|
||||
#include "mozilla/EventStates.h"
|
||||
#include "mozilla/InternalMutationEvent.h"
|
||||
|
|
|
@ -17,5 +17,5 @@ dictionary FontFaceSetLoadEventInit : EventInit {
|
|||
[Constructor(DOMString type, optional FontFaceSetLoadEventInit eventInitDict),
|
||||
Pref="layout.css.font-loading-api.enabled"]
|
||||
interface FontFaceSetLoadEvent : Event {
|
||||
[Cached, Constant] readonly attribute sequence<FontFace> fontfaces;
|
||||
[Cached, Constant, Frozen] readonly attribute sequence<FontFace> fontfaces;
|
||||
};
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
|
||||
#include "mozilla/ArrayUtils.h"
|
||||
|
||||
#include "DateTimeFormat.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIDocument.h"
|
||||
|
@ -48,7 +49,6 @@
|
|||
#include "prtime.h"
|
||||
#include "rdf.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsIDateTimeFormat.h"
|
||||
#include "nsIScriptableDateFormat.h"
|
||||
#include "nsICollation.h"
|
||||
#include "nsCollationCID.h"
|
||||
|
@ -62,7 +62,6 @@ using namespace mozilla;
|
|||
//------------------------------------------------------------------------
|
||||
|
||||
nsIRDFService* nsXULContentUtils::gRDF;
|
||||
nsIDateTimeFormat* nsXULContentUtils::gFormat;
|
||||
nsICollation *nsXULContentUtils::gCollation;
|
||||
|
||||
extern LazyLogModule gXULTemplateLog;
|
||||
|
@ -102,11 +101,6 @@ nsXULContentUtils::Init()
|
|||
#undef XUL_RESOURCE
|
||||
#undef XUL_LITERAL
|
||||
|
||||
gFormat = nsIDateTimeFormat::Create().take();
|
||||
if (!gFormat) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -122,7 +116,6 @@ nsXULContentUtils::Finish()
|
|||
#undef XUL_RESOURCE
|
||||
#undef XUL_LITERAL
|
||||
|
||||
NS_IF_RELEASE(gFormat);
|
||||
NS_IF_RELEASE(gCollation);
|
||||
|
||||
return NS_OK;
|
||||
|
@ -214,11 +207,11 @@ nsXULContentUtils::GetTextForNode(nsIRDFNode* aNode, nsAString& aResult)
|
|||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsAutoString str;
|
||||
rv = gFormat->FormatPRTime(nullptr /* nsILocale* locale */,
|
||||
kDateFormatShort,
|
||||
rv = DateTimeFormat::FormatPRTime(kDateFormatShort,
|
||||
kTimeFormatSeconds,
|
||||
value,
|
||||
str);
|
||||
|
||||
aResult.Assign(str);
|
||||
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
|
|
@ -21,7 +21,6 @@ class nsIRDFNode;
|
|||
class nsIRDFResource;
|
||||
class nsIRDFLiteral;
|
||||
class nsIRDFService;
|
||||
class nsIDateTimeFormat;
|
||||
class nsICollation;
|
||||
|
||||
// errors to pass to LogTemplateError
|
||||
|
@ -86,7 +85,6 @@ class nsXULContentUtils
|
|||
{
|
||||
protected:
|
||||
static nsIRDFService* gRDF;
|
||||
static nsIDateTimeFormat* gFormat;
|
||||
static nsICollation *gCollation;
|
||||
|
||||
static bool gDisableXULCache;
|
||||
|
|
|
@ -61,15 +61,12 @@ NS_DEFINE_NAMED_CID(NS_LANGUAGEATOMSERVICE_CID);
|
|||
NS_DEFINE_NAMED_CID(NS_PLATFORMCHARSET_CID);
|
||||
#ifdef XP_WIN
|
||||
NS_DEFINE_NAMED_CID(NS_COLLATION_CID);
|
||||
NS_DEFINE_NAMED_CID(NS_DATETIMEFORMAT_CID);
|
||||
#endif
|
||||
#ifdef USE_UNIX_LOCALE
|
||||
NS_DEFINE_NAMED_CID(NS_COLLATION_CID);
|
||||
NS_DEFINE_NAMED_CID(NS_DATETIMEFORMAT_CID);
|
||||
#endif
|
||||
#ifdef USE_MAC_LOCALE
|
||||
NS_DEFINE_NAMED_CID(NS_COLLATION_CID);
|
||||
NS_DEFINE_NAMED_CID(NS_DATETIMEFORMAT_CID);
|
||||
#endif
|
||||
|
||||
static const mozilla::Module::CIDEntry kIntlCIDs[] = {
|
||||
|
@ -90,15 +87,12 @@ static const mozilla::Module::CIDEntry kIntlCIDs[] = {
|
|||
{ &kNS_PLATFORMCHARSET_CID, false, nullptr, nsPlatformCharsetConstructor },
|
||||
#ifdef XP_WIN
|
||||
{ &kNS_COLLATION_CID, false, nullptr, nsCollationWinConstructor },
|
||||
{ &kNS_DATETIMEFORMAT_CID, false, nullptr, nsDateTimeFormatWinConstructor },
|
||||
#endif
|
||||
#ifdef USE_UNIX_LOCALE
|
||||
{ &kNS_COLLATION_CID, false, nullptr, nsCollationUnixConstructor },
|
||||
{ &kNS_DATETIMEFORMAT_CID, false, nullptr, nsDateTimeFormatUnixConstructor },
|
||||
#endif
|
||||
#ifdef USE_MAC_LOCALE
|
||||
{ &kNS_COLLATION_CID, false, nullptr, nsCollationMacUCConstructor },
|
||||
{ &kNS_DATETIMEFORMAT_CID, false, nullptr, nsDateTimeFormatMacConstructor },
|
||||
#endif
|
||||
{ nullptr }
|
||||
};
|
||||
|
@ -121,15 +115,12 @@ static const mozilla::Module::ContractIDEntry kIntlContracts[] = {
|
|||
{ NS_PLATFORMCHARSET_CONTRACTID, &kNS_PLATFORMCHARSET_CID },
|
||||
#ifdef XP_WIN
|
||||
{ NS_COLLATION_CONTRACTID, &kNS_COLLATION_CID },
|
||||
{ NS_DATETIMEFORMAT_CONTRACTID, &kNS_DATETIMEFORMAT_CID },
|
||||
#endif
|
||||
#ifdef USE_UNIX_LOCALE
|
||||
{ NS_COLLATION_CONTRACTID, &kNS_COLLATION_CID },
|
||||
{ NS_DATETIMEFORMAT_CONTRACTID, &kNS_DATETIMEFORMAT_CID },
|
||||
#endif
|
||||
#ifdef USE_MAC_LOCALE
|
||||
{ NS_COLLATION_CONTRACTID, &kNS_COLLATION_CID },
|
||||
{ NS_DATETIMEFORMAT_CONTRACTID, &kNS_DATETIMEFORMAT_CID },
|
||||
#endif
|
||||
{ nullptr }
|
||||
};
|
||||
|
|
|
@ -0,0 +1,68 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef mozilla_DateTimeFormat_h
|
||||
#define mozilla_DateTimeFormat_h
|
||||
|
||||
#include <time.h>
|
||||
#include "nsIScriptableDateFormat.h"
|
||||
#include "nsStringGlue.h"
|
||||
#include "prtime.h"
|
||||
|
||||
#ifndef ENABLE_INTL_API
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIUnicodeDecoder.h"
|
||||
#endif
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
class DateTimeFormat {
|
||||
public:
|
||||
// performs a locale sensitive date formatting operation on the time_t parameter
|
||||
static nsresult FormatTime(const nsDateFormatSelector aDateFormatSelector,
|
||||
const nsTimeFormatSelector aTimeFormatSelector,
|
||||
const time_t aTimetTime,
|
||||
nsAString& aStringOut);
|
||||
|
||||
// performs a locale sensitive date formatting operation on the PRTime parameter
|
||||
static nsresult FormatPRTime(const nsDateFormatSelector aDateFormatSelector,
|
||||
const nsTimeFormatSelector aTimeFormatSelector,
|
||||
const PRTime aPrTime,
|
||||
nsAString& aStringOut);
|
||||
|
||||
// performs a locale sensitive date formatting operation on the PRExplodedTime parameter
|
||||
static nsresult FormatPRExplodedTime(const nsDateFormatSelector aDateFormatSelector,
|
||||
const nsTimeFormatSelector aTimeFormatSelector,
|
||||
const PRExplodedTime* aExplodedTime,
|
||||
nsAString& aStringOut);
|
||||
|
||||
static void Shutdown();
|
||||
|
||||
private:
|
||||
DateTimeFormat() = delete;
|
||||
|
||||
static nsresult Initialize();
|
||||
|
||||
#ifdef ENABLE_INTL_API
|
||||
static nsCString* mLocale;
|
||||
#else
|
||||
// performs a locale sensitive date formatting operation on the struct tm parameter
|
||||
static nsresult FormatTMTime(const nsDateFormatSelector aDateFormatSelector,
|
||||
const nsTimeFormatSelector aTimeFormatSelector,
|
||||
const struct tm* aTmTime,
|
||||
nsAString& aStringOut);
|
||||
|
||||
static void LocalePreferred24hour();
|
||||
|
||||
static bool mLocalePreferred24hour; // true if 24 hour format is preferred by current locale
|
||||
static bool mLocaleAMPMfirst; // true if AM/PM string is preferred before the time
|
||||
static nsCOMPtr<nsIUnicodeDecoder> mDecoder;
|
||||
#endif
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif /* mozilla_DateTimeFormat_h */
|
|
@ -0,0 +1,161 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "DateTimeFormat.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsILocaleService.h"
|
||||
#include "unicode/udat.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
nsCString* DateTimeFormat::mLocale = nullptr;
|
||||
|
||||
/*static*/ nsresult
|
||||
DateTimeFormat::Initialize()
|
||||
{
|
||||
nsAutoString localeStr;
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
if (!mLocale) {
|
||||
mLocale = new nsCString();
|
||||
} else if (!mLocale->IsEmpty()) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsILocaleService> localeService =
|
||||
do_GetService(NS_LOCALESERVICE_CONTRACTID, &rv);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsCOMPtr<nsILocale> appLocale;
|
||||
rv = localeService->GetApplicationLocale(getter_AddRefs(appLocale));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = appLocale->GetCategory(NS_LITERAL_STRING("NSILOCALE_TIME"), localeStr);
|
||||
if (NS_SUCCEEDED(rv) && !localeStr.IsEmpty()) {
|
||||
*mLocale = NS_LossyConvertUTF16toASCII(localeStr); // cache locale name
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
// performs a locale sensitive date formatting operation on the time_t parameter
|
||||
/*static*/ nsresult
|
||||
DateTimeFormat::FormatTime(const nsDateFormatSelector aDateFormatSelector,
|
||||
const nsTimeFormatSelector aTimeFormatSelector,
|
||||
const time_t aTimetTime,
|
||||
nsAString& aStringOut)
|
||||
{
|
||||
return FormatPRTime(aDateFormatSelector, aTimeFormatSelector, (aTimetTime * PR_USEC_PER_SEC), aStringOut);
|
||||
}
|
||||
|
||||
// performs a locale sensitive date formatting operation on the PRTime parameter
|
||||
/*static*/ nsresult
|
||||
DateTimeFormat::FormatPRTime(const nsDateFormatSelector aDateFormatSelector,
|
||||
const nsTimeFormatSelector aTimeFormatSelector,
|
||||
const PRTime aPrTime,
|
||||
nsAString& aStringOut)
|
||||
{
|
||||
#define DATETIME_FORMAT_INITIAL_LEN 127
|
||||
int32_t dateTimeLen = 0;
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
// return, nothing to format
|
||||
if (aDateFormatSelector == kDateFormatNone && aTimeFormatSelector == kTimeFormatNone) {
|
||||
aStringOut.Truncate();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// set up locale data
|
||||
rv = Initialize();
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
UDate timeUDate = aPrTime / PR_USEC_PER_MSEC;
|
||||
|
||||
// Get the date style for the formatter:
|
||||
UDateFormatStyle dateStyle;
|
||||
switch (aDateFormatSelector) {
|
||||
case kDateFormatLong:
|
||||
dateStyle = UDAT_LONG;
|
||||
break;
|
||||
case kDateFormatShort:
|
||||
dateStyle = UDAT_SHORT;
|
||||
break;
|
||||
case kDateFormatNone:
|
||||
dateStyle = UDAT_NONE;
|
||||
break;
|
||||
default:
|
||||
NS_ERROR("Unknown nsDateFormatSelector");
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
}
|
||||
|
||||
// Get the time style for the formatter:
|
||||
UDateFormatStyle timeStyle;
|
||||
switch (aTimeFormatSelector) {
|
||||
case kTimeFormatSeconds:
|
||||
timeStyle = UDAT_MEDIUM;
|
||||
break;
|
||||
case kTimeFormatNoSeconds:
|
||||
timeStyle = UDAT_SHORT;
|
||||
break;
|
||||
case kTimeFormatNone:
|
||||
timeStyle = UDAT_NONE;
|
||||
break;
|
||||
default:
|
||||
NS_ERROR("Unknown nsTimeFormatSelector");
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
}
|
||||
|
||||
// generate date/time string
|
||||
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
|
||||
UDateFormat* dateTimeFormat = udat_open(timeStyle, dateStyle, mLocale->get(), nullptr, -1, nullptr, -1, &status);
|
||||
|
||||
if (U_SUCCESS(status) && dateTimeFormat) {
|
||||
aStringOut.SetLength(DATETIME_FORMAT_INITIAL_LEN);
|
||||
dateTimeLen = udat_format(dateTimeFormat, timeUDate, reinterpret_cast<UChar*>(aStringOut.BeginWriting()), DATETIME_FORMAT_INITIAL_LEN, nullptr, &status);
|
||||
aStringOut.SetLength(dateTimeLen);
|
||||
|
||||
if (status == U_BUFFER_OVERFLOW_ERROR) {
|
||||
status = U_ZERO_ERROR;
|
||||
udat_format(dateTimeFormat, timeUDate, reinterpret_cast<UChar*>(aStringOut.BeginWriting()), dateTimeLen, nullptr, &status);
|
||||
}
|
||||
}
|
||||
|
||||
if (U_FAILURE(status)) {
|
||||
rv = NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (dateTimeFormat) {
|
||||
udat_close(dateTimeFormat);
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
// performs a locale sensitive date formatting operation on the PRExplodedTime parameter
|
||||
/*static*/ nsresult
|
||||
DateTimeFormat::FormatPRExplodedTime(const nsDateFormatSelector aDateFormatSelector,
|
||||
const nsTimeFormatSelector aTimeFormatSelector,
|
||||
const PRExplodedTime* aExplodedTime,
|
||||
nsAString& aStringOut)
|
||||
{
|
||||
return FormatPRTime(aDateFormatSelector, aTimeFormatSelector, PR_ImplodeTime(aExplodedTime), aStringOut);
|
||||
}
|
||||
|
||||
/*static*/ void
|
||||
DateTimeFormat::Shutdown()
|
||||
{
|
||||
if (mLocale) {
|
||||
delete mLocale;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,239 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "DateTimeFormat.h"
|
||||
#include "plstr.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsILocaleService.h"
|
||||
#include "nsIPlatformCharset.h"
|
||||
#include "mozilla/dom/EncodingUtils.h"
|
||||
|
||||
using mozilla::dom::EncodingUtils;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
bool DateTimeFormat::mLocalePreferred24hour;
|
||||
bool DateTimeFormat::mLocaleAMPMfirst;
|
||||
nsCOMPtr<nsIUnicodeDecoder> DateTimeFormat::mDecoder;
|
||||
|
||||
/*static*/ nsresult
|
||||
DateTimeFormat::Initialize()
|
||||
{
|
||||
nsAutoString localeStr;
|
||||
nsAutoCString charset;
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
if (mDecoder) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
charset.AssignLiteral("windows-1252");
|
||||
|
||||
nsCOMPtr<nsILocaleService> localeService =
|
||||
do_GetService(NS_LOCALESERVICE_CONTRACTID, &rv);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsCOMPtr<nsILocale> appLocale;
|
||||
rv = localeService->GetApplicationLocale(getter_AddRefs(appLocale));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = appLocale->GetCategory(NS_LITERAL_STRING("NSILOCALE_TIME##PLATFORM"), localeStr);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to get app locale info");
|
||||
}
|
||||
}
|
||||
|
||||
if (NS_SUCCEEDED(rv) && !localeStr.IsEmpty()) {
|
||||
nsCOMPtr<nsIPlatformCharset> platformCharset = do_GetService(NS_PLATFORMCHARSET_CONTRACTID, &rv);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsAutoCString mappedCharset;
|
||||
rv = platformCharset->GetDefaultCharsetForLocale(localeStr, mappedCharset);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
charset = mappedCharset;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mDecoder = EncodingUtils::DecoderForEncoding(charset);
|
||||
|
||||
LocalePreferred24hour();
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
/*static*/ void
|
||||
DateTimeFormat::LocalePreferred24hour()
|
||||
{
|
||||
char str[100];
|
||||
time_t tt;
|
||||
struct tm *tmc;
|
||||
int i;
|
||||
|
||||
tt = time(nullptr);
|
||||
tmc = localtime(&tt);
|
||||
|
||||
tmc->tm_hour=22; // put the test sample hour to 22:00 which is 10PM
|
||||
tmc->tm_min=0; // set the min & sec other number than '2'
|
||||
tmc->tm_sec=0;
|
||||
|
||||
strftime(str, (size_t)99, "%X", (struct tm *)tmc);
|
||||
|
||||
mLocalePreferred24hour = false;
|
||||
for (i=0; str[i]; i++) {
|
||||
if (str[i] == '2') { // if there is any '2', that locale use 0-23 time format
|
||||
mLocalePreferred24hour = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
mLocaleAMPMfirst = true;
|
||||
if (mLocalePreferred24hour == false) {
|
||||
if (str[0] && str[0] == '1') { // if the first character is '1' of 10:00,
|
||||
// AMPM string is located after 10:00
|
||||
mLocaleAMPMfirst = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*static*/ nsresult
|
||||
DateTimeFormat::FormatTime(const nsDateFormatSelector aDateFormatSelector,
|
||||
const nsTimeFormatSelector aTimeFormatSelector,
|
||||
const time_t aTimetTime,
|
||||
nsAString& aStringOut)
|
||||
{
|
||||
struct tm tmTime;
|
||||
memcpy(&tmTime, localtime(&aTimetTime), sizeof(struct tm));
|
||||
return FormatTMTime(aDateFormatSelector, aTimeFormatSelector, &tmTime, aStringOut);
|
||||
}
|
||||
|
||||
// performs a locale sensitive date formatting operation on the struct tm parameter
|
||||
/*static*/ nsresult
|
||||
DateTimeFormat::FormatTMTime(const nsDateFormatSelector aDateFormatSelector,
|
||||
const nsTimeFormatSelector aTimeFormatSelector,
|
||||
const struct tm* aTmTime,
|
||||
nsAString& aStringOut)
|
||||
{
|
||||
#define NSDATETIME_FORMAT_BUFFER_LEN 80
|
||||
char strOut[NSDATETIME_FORMAT_BUFFER_LEN*2]; // buffer for date and time
|
||||
char fmtD[NSDATETIME_FORMAT_BUFFER_LEN], fmtT[NSDATETIME_FORMAT_BUFFER_LEN];
|
||||
nsresult rv;
|
||||
|
||||
// set up locale data
|
||||
(void) Initialize();
|
||||
NS_ENSURE_TRUE(mDecoder, NS_ERROR_NOT_INITIALIZED);
|
||||
|
||||
// set date format
|
||||
if (aDateFormatSelector == kDateFormatLong && aTimeFormatSelector == kTimeFormatSeconds) {
|
||||
PL_strncpy(fmtD, "%c", NSDATETIME_FORMAT_BUFFER_LEN);
|
||||
PL_strncpy(fmtT, "", NSDATETIME_FORMAT_BUFFER_LEN);
|
||||
} else {
|
||||
|
||||
switch (aDateFormatSelector) {
|
||||
case kDateFormatNone:
|
||||
PL_strncpy(fmtD, "", NSDATETIME_FORMAT_BUFFER_LEN);
|
||||
break;
|
||||
case kDateFormatLong:
|
||||
case kDateFormatShort:
|
||||
PL_strncpy(fmtD, "%x", NSDATETIME_FORMAT_BUFFER_LEN);
|
||||
break;
|
||||
default:
|
||||
PL_strncpy(fmtD, "", NSDATETIME_FORMAT_BUFFER_LEN);
|
||||
}
|
||||
|
||||
// set time format
|
||||
switch (aTimeFormatSelector) {
|
||||
case kTimeFormatNone:
|
||||
PL_strncpy(fmtT, "", NSDATETIME_FORMAT_BUFFER_LEN);
|
||||
break;
|
||||
case kTimeFormatSeconds:
|
||||
PL_strncpy(fmtT, "%X", NSDATETIME_FORMAT_BUFFER_LEN);
|
||||
break;
|
||||
case kTimeFormatNoSeconds:
|
||||
PL_strncpy(fmtT,
|
||||
mLocalePreferred24hour ? "%H:%M" : mLocaleAMPMfirst ? "%p %I:%M" : "%I:%M %p",
|
||||
NSDATETIME_FORMAT_BUFFER_LEN);
|
||||
break;
|
||||
default:
|
||||
PL_strncpy(fmtT, "", NSDATETIME_FORMAT_BUFFER_LEN);
|
||||
}
|
||||
}
|
||||
|
||||
// generate date/time string
|
||||
if (strlen(fmtD) && strlen(fmtT)) {
|
||||
PL_strncat(fmtD, " ", NSDATETIME_FORMAT_BUFFER_LEN);
|
||||
PL_strncat(fmtD, fmtT, NSDATETIME_FORMAT_BUFFER_LEN);
|
||||
strftime(strOut, NSDATETIME_FORMAT_BUFFER_LEN, fmtD, aTmTime);
|
||||
} else if (strlen(fmtD) && !strlen(fmtT)) {
|
||||
strftime(strOut, NSDATETIME_FORMAT_BUFFER_LEN, fmtD, aTmTime);
|
||||
} else if (!strlen(fmtD) && strlen(fmtT)) {
|
||||
strftime(strOut, NSDATETIME_FORMAT_BUFFER_LEN, fmtT, aTmTime);
|
||||
} else {
|
||||
PL_strncpy(strOut, "", NSDATETIME_FORMAT_BUFFER_LEN);
|
||||
}
|
||||
|
||||
// convert result to unicode
|
||||
int32_t srcLength = (int32_t) strlen(strOut);
|
||||
int32_t unicharLength = NSDATETIME_FORMAT_BUFFER_LEN*2;
|
||||
char16_t unichars[NSDATETIME_FORMAT_BUFFER_LEN*2]; // buffer for date and time
|
||||
|
||||
rv = mDecoder->Convert(strOut, &srcLength, unichars, &unicharLength);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
aStringOut.Assign(unichars, unicharLength);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
// performs a locale sensitive date formatting operation on the PRTime parameter
|
||||
/*static*/ nsresult
|
||||
DateTimeFormat::FormatPRTime(const nsDateFormatSelector aDateFormatSelector,
|
||||
const nsTimeFormatSelector aTimeFormatSelector,
|
||||
const PRTime aPrTime,
|
||||
nsAString& aStringOut)
|
||||
{
|
||||
PRExplodedTime explodedTime;
|
||||
PR_ExplodeTime(aPrTime, PR_LocalTimeParameters, &explodedTime);
|
||||
|
||||
return FormatPRExplodedTime(aDateFormatSelector, aTimeFormatSelector, &explodedTime, aStringOut);
|
||||
}
|
||||
|
||||
// performs a locale sensitive date formatting operation on the PRExplodedTime parameter
|
||||
/*static*/ nsresult
|
||||
DateTimeFormat::FormatPRExplodedTime(const nsDateFormatSelector aDateFormatSelector,
|
||||
const nsTimeFormatSelector aTimeFormatSelector,
|
||||
const PRExplodedTime* aExplodedTime,
|
||||
nsAString& aStringOut)
|
||||
{
|
||||
struct tm tmTime;
|
||||
/* be safe and set all members of struct tm to zero
|
||||
*
|
||||
* there are other fields in the tm struct that we aren't setting
|
||||
* (tm_isdst, tm_gmtoff, tm_zone, should we set these?) and since
|
||||
* tmTime is on the stack, it may be filled with garbage, but
|
||||
* the garbage may vary. (this may explain why some saw bug #10412, and
|
||||
* others did not.
|
||||
*
|
||||
* when tmTime is passed to strftime() with garbage bad things may happen.
|
||||
* see bug #10412
|
||||
*/
|
||||
memset( &tmTime, 0, sizeof(tmTime) );
|
||||
|
||||
tmTime.tm_yday = aExplodedTime->tm_yday;
|
||||
tmTime.tm_wday = aExplodedTime->tm_wday;
|
||||
tmTime.tm_year = aExplodedTime->tm_year;
|
||||
tmTime.tm_year -= 1900;
|
||||
tmTime.tm_mon = aExplodedTime->tm_month;
|
||||
tmTime.tm_mday = aExplodedTime->tm_mday;
|
||||
tmTime.tm_hour = aExplodedTime->tm_hour;
|
||||
tmTime.tm_min = aExplodedTime->tm_min;
|
||||
tmTime.tm_sec = aExplodedTime->tm_sec;
|
||||
|
||||
return FormatTMTime(aDateFormatSelector, aTimeFormatSelector, &tmTime, aStringOut);
|
||||
}
|
||||
|
||||
/*static*/ void
|
||||
DateTimeFormat::Shutdown()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
|
@ -6,7 +6,6 @@
|
|||
|
||||
UNIFIED_SOURCES += [
|
||||
'nsCollationMacUC.cpp',
|
||||
'nsDateTimeFormatMac.cpp',
|
||||
'nsMacCharset.cpp',
|
||||
]
|
||||
|
||||
|
|
|
@ -1,266 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include <CoreFoundation/CoreFoundation.h>
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsDateTimeFormatMac.h"
|
||||
#include <CoreFoundation/CFDateFormatter.h>
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsILocaleService.h"
|
||||
#include "nsCRT.h"
|
||||
#include "plstr.h"
|
||||
#include "nsUnicharUtils.h"
|
||||
#include "nsTArray.h"
|
||||
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsDateTimeFormatMac, nsIDateTimeFormat)
|
||||
|
||||
nsresult nsDateTimeFormatMac::Initialize(nsILocale* locale)
|
||||
{
|
||||
nsAutoString localeStr;
|
||||
nsAutoString category(NS_LITERAL_STRING("NSILOCALE_TIME"));
|
||||
nsresult res;
|
||||
|
||||
// use cached info if match with stored locale
|
||||
if (nullptr == locale) {
|
||||
if (!mLocale.IsEmpty() &&
|
||||
mLocale.Equals(mAppLocale, nsCaseInsensitiveStringComparator())) {
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
else {
|
||||
res = locale->GetCategory(category, localeStr);
|
||||
if (NS_SUCCEEDED(res) && !localeStr.IsEmpty()) {
|
||||
if (!mLocale.IsEmpty() &&
|
||||
mLocale.Equals(localeStr,
|
||||
nsCaseInsensitiveStringComparator())) {
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// get application locale
|
||||
nsCOMPtr<nsILocaleService> localeService =
|
||||
do_GetService(NS_LOCALESERVICE_CONTRACTID, &res);
|
||||
if (NS_SUCCEEDED(res)) {
|
||||
nsCOMPtr<nsILocale> appLocale;
|
||||
res = localeService->GetApplicationLocale(getter_AddRefs(appLocale));
|
||||
if (NS_SUCCEEDED(res)) {
|
||||
res = appLocale->GetCategory(category, localeStr);
|
||||
if (NS_SUCCEEDED(res) && !localeStr.IsEmpty()) {
|
||||
mAppLocale = localeStr; // cache app locale name
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// use app default if no locale specified
|
||||
if (nullptr == locale) {
|
||||
mUseDefaultLocale = true;
|
||||
}
|
||||
else {
|
||||
mUseDefaultLocale = false;
|
||||
res = locale->GetCategory(category, localeStr);
|
||||
}
|
||||
|
||||
if (NS_SUCCEEDED(res) && !localeStr.IsEmpty()) {
|
||||
mLocale.Assign(localeStr); // cache locale name
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
// performs a locale sensitive date formatting operation on the time_t parameter
|
||||
nsresult nsDateTimeFormatMac::FormatTime(nsILocale* locale,
|
||||
const nsDateFormatSelector dateFormatSelector,
|
||||
const nsTimeFormatSelector timeFormatSelector,
|
||||
const time_t timetTime,
|
||||
nsAString& stringOut)
|
||||
{
|
||||
struct tm tmTime;
|
||||
return FormatTMTime(locale, dateFormatSelector, timeFormatSelector, localtime_r(&timetTime, &tmTime), stringOut);
|
||||
}
|
||||
|
||||
// performs a locale sensitive date formatting operation on the struct tm parameter
|
||||
nsresult nsDateTimeFormatMac::FormatTMTime(nsILocale* locale,
|
||||
const nsDateFormatSelector dateFormatSelector,
|
||||
const nsTimeFormatSelector timeFormatSelector,
|
||||
const struct tm* tmTime,
|
||||
nsAString& stringOut)
|
||||
{
|
||||
nsresult res = NS_OK;
|
||||
|
||||
// set up locale data
|
||||
(void) Initialize(locale);
|
||||
|
||||
// return, nothing to format
|
||||
if (dateFormatSelector == kDateFormatNone && timeFormatSelector == kTimeFormatNone) {
|
||||
stringOut.Truncate();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_ASSERTION(tmTime->tm_mon >= 0, "tm is not set correctly");
|
||||
NS_ASSERTION(tmTime->tm_mday >= 1, "tm is not set correctly");
|
||||
NS_ASSERTION(tmTime->tm_hour >= 0, "tm is not set correctly");
|
||||
NS_ASSERTION(tmTime->tm_min >= 0, "tm is not set correctly");
|
||||
NS_ASSERTION(tmTime->tm_sec >= 0, "tm is not set correctly");
|
||||
NS_ASSERTION(tmTime->tm_wday >= 0, "tm is not set correctly");
|
||||
|
||||
// Got the locale for the formatter:
|
||||
CFLocaleRef formatterLocale;
|
||||
if (!locale) {
|
||||
formatterLocale = CFLocaleCopyCurrent();
|
||||
} else {
|
||||
CFStringRef localeStr = CFStringCreateWithCharacters(nullptr,
|
||||
reinterpret_cast<const UniChar*>(mLocale.get()),
|
||||
mLocale.Length());
|
||||
formatterLocale = CFLocaleCreate(nullptr, localeStr);
|
||||
CFRelease(localeStr);
|
||||
}
|
||||
|
||||
// Get the date style for the formatter:
|
||||
CFDateFormatterStyle dateStyle;
|
||||
switch (dateFormatSelector) {
|
||||
case kDateFormatLong:
|
||||
dateStyle = kCFDateFormatterLongStyle;
|
||||
break;
|
||||
case kDateFormatShort:
|
||||
dateStyle = kCFDateFormatterShortStyle;
|
||||
break;
|
||||
case kDateFormatYearMonth:
|
||||
case kDateFormatWeekday:
|
||||
dateStyle = kCFDateFormatterNoStyle; // formats handled below
|
||||
break;
|
||||
case kDateFormatNone:
|
||||
dateStyle = kCFDateFormatterNoStyle;
|
||||
break;
|
||||
default:
|
||||
NS_ERROR("Unknown nsDateFormatSelector");
|
||||
res = NS_ERROR_FAILURE;
|
||||
dateStyle = kCFDateFormatterNoStyle;
|
||||
}
|
||||
|
||||
// Get the time style for the formatter:
|
||||
CFDateFormatterStyle timeStyle;
|
||||
switch (timeFormatSelector) {
|
||||
case kTimeFormatSeconds:
|
||||
case kTimeFormatSecondsForce24Hour: // 24 hour part fixed below
|
||||
timeStyle = kCFDateFormatterMediumStyle;
|
||||
break;
|
||||
case kTimeFormatNoSeconds:
|
||||
case kTimeFormatNoSecondsForce24Hour: // 24 hour part fixed below
|
||||
timeStyle = kCFDateFormatterShortStyle;
|
||||
break;
|
||||
case kTimeFormatNone:
|
||||
timeStyle = kCFDateFormatterNoStyle;
|
||||
break;
|
||||
default:
|
||||
NS_ERROR("Unknown nsTimeFormatSelector");
|
||||
res = NS_ERROR_FAILURE;
|
||||
timeStyle = kCFDateFormatterNoStyle;
|
||||
}
|
||||
|
||||
// Create the formatter and fix up its formatting as necessary:
|
||||
CFDateFormatterRef formatter =
|
||||
CFDateFormatterCreate(nullptr, formatterLocale, dateStyle, timeStyle);
|
||||
|
||||
CFRelease(formatterLocale);
|
||||
|
||||
if (dateFormatSelector == kDateFormatYearMonth ||
|
||||
dateFormatSelector == kDateFormatWeekday) {
|
||||
CFStringRef dateFormat =
|
||||
dateFormatSelector == kDateFormatYearMonth ? CFSTR("yyyy/MM ") : CFSTR("EEE ");
|
||||
|
||||
CFStringRef oldFormat = CFDateFormatterGetFormat(formatter);
|
||||
CFMutableStringRef newFormat = CFStringCreateMutableCopy(nullptr, 0, oldFormat);
|
||||
CFStringInsert(newFormat, 0, dateFormat);
|
||||
CFDateFormatterSetFormat(formatter, newFormat);
|
||||
CFRelease(newFormat); // note we don't own oldFormat
|
||||
}
|
||||
|
||||
if (timeFormatSelector == kTimeFormatSecondsForce24Hour ||
|
||||
timeFormatSelector == kTimeFormatNoSecondsForce24Hour) {
|
||||
// Replace "h" with "H", and remove "a":
|
||||
CFStringRef oldFormat = CFDateFormatterGetFormat(formatter);
|
||||
CFMutableStringRef newFormat = CFStringCreateMutableCopy(nullptr, 0, oldFormat);
|
||||
CFIndex replaceCount = CFStringFindAndReplace(newFormat,
|
||||
CFSTR("h"), CFSTR("H"),
|
||||
CFRangeMake(0, CFStringGetLength(newFormat)),
|
||||
0);
|
||||
NS_ASSERTION(replaceCount <= 2, "Unexpected number of \"h\" occurrences");
|
||||
replaceCount = CFStringFindAndReplace(newFormat,
|
||||
CFSTR("a"), CFSTR(""),
|
||||
CFRangeMake(0, CFStringGetLength(newFormat)),
|
||||
0);
|
||||
NS_ASSERTION(replaceCount <= 1, "Unexpected number of \"a\" occurrences");
|
||||
CFDateFormatterSetFormat(formatter, newFormat);
|
||||
CFRelease(newFormat); // note we don't own oldFormat
|
||||
}
|
||||
|
||||
// Now get the formatted date:
|
||||
CFGregorianDate date;
|
||||
date.second = tmTime->tm_sec;
|
||||
date.minute = tmTime->tm_min;
|
||||
date.hour = tmTime->tm_hour;
|
||||
date.day = tmTime->tm_mday; // Mac is 1-based, tm is 1-based
|
||||
date.month = tmTime->tm_mon + 1; // Mac is 1-based, tm is 0-based
|
||||
date.year = tmTime->tm_year + 1900;
|
||||
|
||||
CFTimeZoneRef timeZone = CFTimeZoneCopySystem(); // tmTime is in local time
|
||||
CFAbsoluteTime absTime = CFGregorianDateGetAbsoluteTime(date, timeZone);
|
||||
CFRelease(timeZone);
|
||||
|
||||
CFStringRef formattedDate = CFDateFormatterCreateStringWithAbsoluteTime(nullptr,
|
||||
formatter,
|
||||
absTime);
|
||||
|
||||
CFIndex stringLen = CFStringGetLength(formattedDate);
|
||||
|
||||
AutoTArray<UniChar, 256> stringBuffer;
|
||||
stringBuffer.SetLength(stringLen + 1);
|
||||
CFStringGetCharacters(formattedDate, CFRangeMake(0, stringLen), stringBuffer.Elements());
|
||||
stringOut.Assign(reinterpret_cast<char16_t*>(stringBuffer.Elements()), stringLen);
|
||||
|
||||
CFRelease(formattedDate);
|
||||
CFRelease(formatter);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
// performs a locale sensitive date formatting operation on the PRTime parameter
|
||||
nsresult nsDateTimeFormatMac::FormatPRTime(nsILocale* locale,
|
||||
const nsDateFormatSelector dateFormatSelector,
|
||||
const nsTimeFormatSelector timeFormatSelector,
|
||||
const PRTime prTime,
|
||||
nsAString& stringOut)
|
||||
{
|
||||
PRExplodedTime explodedTime;
|
||||
PR_ExplodeTime(prTime, PR_LocalTimeParameters, &explodedTime);
|
||||
|
||||
return FormatPRExplodedTime(locale, dateFormatSelector, timeFormatSelector, &explodedTime, stringOut);
|
||||
}
|
||||
|
||||
// performs a locale sensitive date formatting operation on the PRExplodedTime parameter
|
||||
nsresult nsDateTimeFormatMac::FormatPRExplodedTime(nsILocale* locale,
|
||||
const nsDateFormatSelector dateFormatSelector,
|
||||
const nsTimeFormatSelector timeFormatSelector,
|
||||
const PRExplodedTime* explodedTime,
|
||||
nsAString& stringOut)
|
||||
{
|
||||
struct tm tmTime;
|
||||
memset( &tmTime, 0, sizeof(tmTime) );
|
||||
|
||||
tmTime.tm_yday = explodedTime->tm_yday;
|
||||
tmTime.tm_wday = explodedTime->tm_wday;
|
||||
tmTime.tm_year = explodedTime->tm_year;
|
||||
tmTime.tm_year -= 1900;
|
||||
tmTime.tm_mon = explodedTime->tm_month;
|
||||
tmTime.tm_mday = explodedTime->tm_mday;
|
||||
tmTime.tm_hour = explodedTime->tm_hour;
|
||||
tmTime.tm_min = explodedTime->tm_min;
|
||||
tmTime.tm_sec = explodedTime->tm_sec;
|
||||
|
||||
return FormatTMTime(locale, dateFormatSelector, timeFormatSelector, &tmTime, stringOut);
|
||||
}
|
||||
|
|
@ -1,61 +0,0 @@
|
|||
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
#ifndef nsDateTimeFormatMac_h__
|
||||
#define nsDateTimeFormatMac_h__
|
||||
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIDateTimeFormat.h"
|
||||
|
||||
|
||||
class nsDateTimeFormatMac : public nsIDateTimeFormat {
|
||||
|
||||
public:
|
||||
NS_DECL_THREADSAFE_ISUPPORTS
|
||||
|
||||
// performs a locale sensitive date formatting operation on the time_t parameter
|
||||
NS_IMETHOD FormatTime(nsILocale* locale,
|
||||
const nsDateFormatSelector dateFormatSelector,
|
||||
const nsTimeFormatSelector timeFormatSelector,
|
||||
const time_t timetTime,
|
||||
nsAString& stringOut) override;
|
||||
|
||||
// performs a locale sensitive date formatting operation on the struct tm parameter
|
||||
NS_IMETHOD FormatTMTime(nsILocale* locale,
|
||||
const nsDateFormatSelector dateFormatSelector,
|
||||
const nsTimeFormatSelector timeFormatSelector,
|
||||
const struct tm* tmTime,
|
||||
nsAString& stringOut) override;
|
||||
// performs a locale sensitive date formatting operation on the PRTime parameter
|
||||
NS_IMETHOD FormatPRTime(nsILocale* locale,
|
||||
const nsDateFormatSelector dateFormatSelector,
|
||||
const nsTimeFormatSelector timeFormatSelector,
|
||||
const PRTime prTime,
|
||||
nsAString& stringOut) override;
|
||||
|
||||
// performs a locale sensitive date formatting operation on the PRExplodedTime parameter
|
||||
NS_IMETHOD FormatPRExplodedTime(nsILocale* locale,
|
||||
const nsDateFormatSelector dateFormatSelector,
|
||||
const nsTimeFormatSelector timeFormatSelector,
|
||||
const PRExplodedTime* explodedTime,
|
||||
nsAString& stringOut) override;
|
||||
|
||||
nsDateTimeFormatMac() {}
|
||||
|
||||
protected:
|
||||
virtual ~nsDateTimeFormatMac() {}
|
||||
|
||||
private:
|
||||
// init this interface to a specified locale
|
||||
NS_IMETHOD Initialize(nsILocale* locale);
|
||||
|
||||
nsString mLocale;
|
||||
nsString mAppLocale;
|
||||
bool mUseDefaultLocale;
|
||||
};
|
||||
|
||||
#endif /* nsDateTimeFormatMac_h__ */
|
|
@ -25,10 +25,9 @@ XPIDL_SOURCES += [
|
|||
XPIDL_MODULE = 'locale'
|
||||
|
||||
EXPORTS += [
|
||||
'DateTimeFormat.h',
|
||||
'nsCollation.h',
|
||||
'nsCollationCID.h',
|
||||
'nsDateTimeFormatCID.h',
|
||||
'nsIDateTimeFormat.h',
|
||||
'nsILanguageAtomService.h',
|
||||
'nsIPlatformCharset.h',
|
||||
'nsPosixLocale.h',
|
||||
|
@ -38,7 +37,6 @@ EXPORTS += [
|
|||
|
||||
UNIFIED_SOURCES += [
|
||||
'nsCollation.cpp',
|
||||
'nsIDateTimeFormat.cpp',
|
||||
'nsLanguageAtomService.cpp',
|
||||
'nsLocale.cpp',
|
||||
'nsLocaleService.cpp',
|
||||
|
@ -46,6 +44,15 @@ UNIFIED_SOURCES += [
|
|||
'nsUConvPropertySearch.cpp',
|
||||
]
|
||||
|
||||
if CONFIG['ENABLE_INTL_API']:
|
||||
UNIFIED_SOURCES += [
|
||||
'DateTimeFormatICU.cpp',
|
||||
]
|
||||
else:
|
||||
UNIFIED_SOURCES += [
|
||||
'DateTimeFormatUnix.cpp',
|
||||
]
|
||||
|
||||
EXTRA_JS_MODULES += [
|
||||
'PluralForm.jsm',
|
||||
]
|
||||
|
|
|
@ -1,20 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
#ifndef nsDateTimeFormatCID_h__
|
||||
#define nsDateTimeFormatCID_h__
|
||||
|
||||
|
||||
#include "nscore.h"
|
||||
#include "nsISupports.h"
|
||||
|
||||
#define NS_DATETIMEFORMAT_CONTRACTID "@mozilla.org/intl/datetimeformat;1"
|
||||
|
||||
// {0704E7C0-A758-11d2-9119-006008A6EDF6}
|
||||
#define NS_DATETIMEFORMAT_CID \
|
||||
{ 0x704e7c0, 0xa758, 0x11d2, \
|
||||
{ 0x91, 0x19, 0x0, 0x60, 0x8, 0xa6, 0xed, 0xf6 } }
|
||||
|
||||
#endif // nsDateTimeFormatCID_h__
|
||||
|
|
@ -1,39 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "nsIDateTimeFormat.h"
|
||||
#include "mozilla/RefPtr.h"
|
||||
|
||||
#if defined(XP_MACOSX)
|
||||
#define USE_MAC_LOCALE
|
||||
#elif defined(XP_UNIX)
|
||||
#define USE_UNIX_LOCALE
|
||||
#endif
|
||||
|
||||
#ifdef XP_WIN
|
||||
#include "windows/nsDateTimeFormatWin.h"
|
||||
#endif
|
||||
#ifdef USE_UNIX_LOCALE
|
||||
#include "unix/nsDateTimeFormatUnix.h"
|
||||
#endif
|
||||
#ifdef USE_MAC_LOCALE
|
||||
#include "mac/nsDateTimeFormatMac.h"
|
||||
#endif
|
||||
|
||||
using mozilla::MakeAndAddRef;
|
||||
|
||||
/*static*/ already_AddRefed<nsIDateTimeFormat>
|
||||
nsIDateTimeFormat::Create()
|
||||
{
|
||||
#ifdef XP_WIN
|
||||
return MakeAndAddRef<nsDateTimeFormatWin>();
|
||||
#elif defined(USE_UNIX_LOCALE)
|
||||
return MakeAndAddRef<nsDateTimeFormatUnix>();
|
||||
#elif defined(USE_MAC_LOCALE)
|
||||
return MakeAndAddRef<nsDateTimeFormatMac>();
|
||||
#else
|
||||
return nullptr;
|
||||
#endif
|
||||
}
|
|
@ -1,69 +0,0 @@
|
|||
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
#ifndef nsIDateTimeFormat_h__
|
||||
#define nsIDateTimeFormat_h__
|
||||
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nscore.h"
|
||||
#include "nsStringGlue.h"
|
||||
#include "nsILocale.h"
|
||||
#include "nsIScriptableDateFormat.h"
|
||||
#include "prtime.h"
|
||||
#include <time.h>
|
||||
|
||||
|
||||
// {2BBAA0B0-A591-11d2-9119-006008A6EDF6}
|
||||
#define NS_IDATETIMEFORMAT_IID \
|
||||
{ 0x2bbaa0b0, 0xa591, 0x11d2, \
|
||||
{ 0x91, 0x19, 0x0, 0x60, 0x8, 0xa6, 0xed, 0xf6 } }
|
||||
|
||||
|
||||
// Locale sensitive date and time format interface
|
||||
//
|
||||
class nsIDateTimeFormat : public nsISupports {
|
||||
protected:
|
||||
nsIDateTimeFormat() {}
|
||||
virtual ~nsIDateTimeFormat() {}
|
||||
|
||||
public:
|
||||
NS_DECLARE_STATIC_IID_ACCESSOR(NS_IDATETIMEFORMAT_IID)
|
||||
|
||||
static already_AddRefed<nsIDateTimeFormat> Create();
|
||||
|
||||
// performs a locale sensitive date formatting operation on the time_t parameter
|
||||
NS_IMETHOD FormatTime(nsILocale* locale,
|
||||
const nsDateFormatSelector dateFormatSelector,
|
||||
const nsTimeFormatSelector timeFormatSelector,
|
||||
const time_t timetTime,
|
||||
nsAString& stringOut) = 0;
|
||||
|
||||
// performs a locale sensitive date formatting operation on the struct tm parameter
|
||||
NS_IMETHOD FormatTMTime(nsILocale* locale,
|
||||
const nsDateFormatSelector dateFormatSelector,
|
||||
const nsTimeFormatSelector timeFormatSelector,
|
||||
const struct tm* tmTime,
|
||||
nsAString& stringOut) = 0;
|
||||
|
||||
// performs a locale sensitive date formatting operation on the PRTime parameter
|
||||
NS_IMETHOD FormatPRTime(nsILocale* locale,
|
||||
const nsDateFormatSelector dateFormatSelector,
|
||||
const nsTimeFormatSelector timeFormatSelector,
|
||||
const PRTime prTime,
|
||||
nsAString& stringOut) = 0;
|
||||
|
||||
// performs a locale sensitive date formatting operation on the PRExplodedTime parameter
|
||||
NS_IMETHOD FormatPRExplodedTime(nsILocale* locale,
|
||||
const nsDateFormatSelector dateFormatSelector,
|
||||
const nsTimeFormatSelector timeFormatSelector,
|
||||
const PRExplodedTime* explodedTime,
|
||||
nsAString& stringOut) = 0;
|
||||
};
|
||||
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(nsIDateTimeFormat, NS_IDATETIMEFORMAT_IID)
|
||||
|
||||
#endif /* nsIDateTimeFormat_h__ */
|
|
@ -7,7 +7,6 @@
|
|||
#define nsLocaleConstructors_h__
|
||||
|
||||
#include "nsCollationCID.h"
|
||||
#include "nsDateTimeFormatCID.h"
|
||||
#include "mozilla/ModuleUtils.h"
|
||||
#include "nsILocaleService.h"
|
||||
#include "nsIScriptableDateFormat.h"
|
||||
|
@ -25,17 +24,14 @@
|
|||
|
||||
#ifdef XP_WIN
|
||||
#include "windows/nsCollationWin.h"
|
||||
#include "windows/nsDateTimeFormatWin.h"
|
||||
#endif
|
||||
|
||||
#ifdef USE_MAC_LOCALE
|
||||
#include "mac/nsCollationMacUC.h"
|
||||
#include "mac/nsDateTimeFormatMac.h"
|
||||
#endif
|
||||
|
||||
#ifdef USE_UNIX_LOCALE
|
||||
#include "unix/nsCollationUnix.h"
|
||||
#include "unix/nsDateTimeFormatUnix.h"
|
||||
#endif
|
||||
|
||||
#define NSLOCALE_MAKE_CTOR(ctor_, iface_, func_) \
|
||||
|
@ -63,17 +59,14 @@ NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPlatformCharset, Init)
|
|||
|
||||
#ifdef XP_WIN
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsCollationWin)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDateTimeFormatWin)
|
||||
#endif
|
||||
|
||||
#ifdef USE_UNIX_LOCALE
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsCollationUnix)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDateTimeFormatUnix)
|
||||
#endif
|
||||
|
||||
#ifdef USE_MAC_LOCALE
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsCollationMacUC)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDateTimeFormatMac)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
@ -3,16 +3,14 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "DateTimeFormat.h"
|
||||
#include "mozilla/Sprintf.h"
|
||||
#include "nsILocaleService.h"
|
||||
#include "nsDateTimeFormatCID.h"
|
||||
#include "nsIDateTimeFormat.h"
|
||||
#include "nsIScriptableDateFormat.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
|
||||
static NS_DEFINE_CID(kLocaleServiceCID, NS_LOCALESERVICE_CID);
|
||||
static NS_DEFINE_CID(kDateTimeFormatCID, NS_DATETIMEFORMAT_CID);
|
||||
|
||||
class nsScriptableDateFormat : public nsIScriptableDateFormat {
|
||||
public:
|
||||
|
@ -89,9 +87,6 @@ NS_IMETHODIMP nsScriptableDateFormat::FormatDateTime(
|
|||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDateTimeFormat> dateTimeFormat(do_CreateInstance(kDateTimeFormatCID, &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
tm tmTime;
|
||||
time_t timetTime;
|
||||
|
||||
|
@ -107,7 +102,7 @@ NS_IMETHODIMP nsScriptableDateFormat::FormatDateTime(
|
|||
timetTime = mktime(&tmTime);
|
||||
|
||||
if ((time_t)-1 != timetTime) {
|
||||
rv = dateTimeFormat->FormatTime(locale, dateFormatSelector, timeFormatSelector,
|
||||
rv = mozilla::DateTimeFormat::FormatTime(dateFormatSelector, timeFormatSelector,
|
||||
timetTime, mStringOut);
|
||||
}
|
||||
else {
|
||||
|
@ -118,7 +113,7 @@ NS_IMETHODIMP nsScriptableDateFormat::FormatDateTime(
|
|||
if (PR_SUCCESS != PR_ParseTimeString(string, false, &prtime))
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
rv = dateTimeFormat->FormatPRTime(locale, dateFormatSelector, timeFormatSelector,
|
||||
rv = mozilla::DateTimeFormat::FormatPRTime(dateFormatSelector, timeFormatSelector,
|
||||
prtime, mStringOut);
|
||||
}
|
||||
if (NS_SUCCEEDED(rv))
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
|
||||
SOURCES += [
|
||||
'nsCollationUnix.cpp',
|
||||
'nsDateTimeFormatUnix.cpp',
|
||||
'nsPosixLocale.cpp',
|
||||
]
|
||||
|
||||
|
|
|
@ -1,284 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include <locale.h>
|
||||
#include "plstr.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsDateTimeFormatUnix.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsILocaleService.h"
|
||||
#include "nsIPlatformCharset.h"
|
||||
#include "nsPosixLocale.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsUnicharUtils.h"
|
||||
#include "mozilla/dom/EncodingUtils.h"
|
||||
|
||||
using mozilla::dom::EncodingUtils;
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsDateTimeFormatUnix, nsIDateTimeFormat)
|
||||
|
||||
// init this interface to a specified locale
|
||||
nsresult nsDateTimeFormatUnix::Initialize(nsILocale* locale)
|
||||
{
|
||||
nsAutoString localeStr;
|
||||
NS_NAMED_LITERAL_STRING(aCategory, "NSILOCALE_TIME##PLATFORM");
|
||||
nsresult res = NS_OK;
|
||||
|
||||
// use cached info if match with stored locale
|
||||
if (!locale) {
|
||||
if (!mLocale.IsEmpty() &&
|
||||
mLocale.Equals(mAppLocale, nsCaseInsensitiveStringComparator())) {
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
else {
|
||||
res = locale->GetCategory(aCategory, localeStr);
|
||||
if (NS_SUCCEEDED(res) && !localeStr.IsEmpty()) {
|
||||
if (!mLocale.IsEmpty() &&
|
||||
mLocale.Equals(localeStr,
|
||||
nsCaseInsensitiveStringComparator())) {
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mCharset.AssignLiteral("windows-1252");
|
||||
mPlatformLocale.AssignLiteral("en_US");
|
||||
|
||||
// get locale name string, use app default if no locale specified
|
||||
if (!locale) {
|
||||
nsCOMPtr<nsILocaleService> localeService =
|
||||
do_GetService(NS_LOCALESERVICE_CONTRACTID, &res);
|
||||
if (NS_SUCCEEDED(res)) {
|
||||
nsCOMPtr<nsILocale> appLocale;
|
||||
res = localeService->GetApplicationLocale(getter_AddRefs(appLocale));
|
||||
if (NS_SUCCEEDED(res)) {
|
||||
res = appLocale->GetCategory(aCategory, localeStr);
|
||||
if (NS_SUCCEEDED(res) && !localeStr.IsEmpty()) {
|
||||
NS_ASSERTION(NS_SUCCEEDED(res), "failed to get app locale info");
|
||||
mAppLocale = localeStr; // cache app locale name
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
res = locale->GetCategory(aCategory, localeStr);
|
||||
NS_ASSERTION(NS_SUCCEEDED(res), "failed to get locale info");
|
||||
}
|
||||
|
||||
if (NS_SUCCEEDED(res) && !localeStr.IsEmpty()) {
|
||||
mLocale = localeStr; // cache locale name
|
||||
|
||||
nsPosixLocale::GetPlatformLocale(mLocale, mPlatformLocale);
|
||||
|
||||
nsCOMPtr <nsIPlatformCharset> platformCharset = do_GetService(NS_PLATFORMCHARSET_CONTRACTID, &res);
|
||||
if (NS_SUCCEEDED(res)) {
|
||||
nsAutoCString mappedCharset;
|
||||
res = platformCharset->GetDefaultCharsetForLocale(mLocale, mappedCharset);
|
||||
if (NS_SUCCEEDED(res)) {
|
||||
mCharset = mappedCharset;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mDecoder = EncodingUtils::DecoderForEncoding(mCharset);
|
||||
|
||||
LocalePreferred24hour();
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
void nsDateTimeFormatUnix::LocalePreferred24hour()
|
||||
{
|
||||
char str[100];
|
||||
time_t tt;
|
||||
struct tm *tmc;
|
||||
int i;
|
||||
|
||||
tt = time(nullptr);
|
||||
tmc = localtime(&tt);
|
||||
|
||||
tmc->tm_hour=22; // put the test sample hour to 22:00 which is 10PM
|
||||
tmc->tm_min=0; // set the min & sec other number than '2'
|
||||
tmc->tm_sec=0;
|
||||
|
||||
char *temp = setlocale(LC_TIME, mPlatformLocale.get());
|
||||
strftime(str, (size_t)99, "%X", (struct tm *)tmc);
|
||||
|
||||
(void) setlocale(LC_TIME, temp);
|
||||
|
||||
mLocalePreferred24hour = false;
|
||||
for (i=0; str[i]; i++) {
|
||||
if (str[i] == '2') { // if there is any '2', that locale use 0-23 time format
|
||||
mLocalePreferred24hour = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
mLocaleAMPMfirst = true;
|
||||
if (mLocalePreferred24hour == false) {
|
||||
if (str[0] && str[0] == '1') { // if the first character is '1' of 10:00,
|
||||
// AMPM string is located after 10:00
|
||||
mLocaleAMPMfirst = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nsresult nsDateTimeFormatUnix::FormatTime(nsILocale* locale,
|
||||
const nsDateFormatSelector dateFormatSelector,
|
||||
const nsTimeFormatSelector timeFormatSelector,
|
||||
const time_t timetTime,
|
||||
nsAString& stringOut)
|
||||
{
|
||||
struct tm tmTime;
|
||||
memcpy(&tmTime, localtime(&timetTime), sizeof(struct tm));
|
||||
return FormatTMTime(locale, dateFormatSelector, timeFormatSelector, &tmTime, stringOut);
|
||||
}
|
||||
|
||||
// performs a locale sensitive date formatting operation on the struct tm parameter
|
||||
nsresult nsDateTimeFormatUnix::FormatTMTime(nsILocale* locale,
|
||||
const nsDateFormatSelector dateFormatSelector,
|
||||
const nsTimeFormatSelector timeFormatSelector,
|
||||
const struct tm* tmTime,
|
||||
nsAString& stringOut)
|
||||
{
|
||||
#define NSDATETIME_FORMAT_BUFFER_LEN 80
|
||||
char strOut[NSDATETIME_FORMAT_BUFFER_LEN*2]; // buffer for date and time
|
||||
char fmtD[NSDATETIME_FORMAT_BUFFER_LEN], fmtT[NSDATETIME_FORMAT_BUFFER_LEN];
|
||||
nsresult rv;
|
||||
|
||||
|
||||
// set up locale data
|
||||
(void) Initialize(locale);
|
||||
NS_ENSURE_TRUE(mDecoder, NS_ERROR_NOT_INITIALIZED);
|
||||
|
||||
// set date format
|
||||
if (dateFormatSelector == kDateFormatLong && timeFormatSelector == kTimeFormatSeconds) {
|
||||
PL_strncpy(fmtD, "%c", NSDATETIME_FORMAT_BUFFER_LEN);
|
||||
PL_strncpy(fmtT, "", NSDATETIME_FORMAT_BUFFER_LEN);
|
||||
} else {
|
||||
|
||||
switch (dateFormatSelector) {
|
||||
case kDateFormatNone:
|
||||
PL_strncpy(fmtD, "", NSDATETIME_FORMAT_BUFFER_LEN);
|
||||
break;
|
||||
case kDateFormatLong:
|
||||
case kDateFormatShort:
|
||||
PL_strncpy(fmtD, "%x", NSDATETIME_FORMAT_BUFFER_LEN);
|
||||
break;
|
||||
case kDateFormatYearMonth:
|
||||
PL_strncpy(fmtD, "%Y/%m", NSDATETIME_FORMAT_BUFFER_LEN);
|
||||
break;
|
||||
case kDateFormatWeekday:
|
||||
PL_strncpy(fmtD, "%a", NSDATETIME_FORMAT_BUFFER_LEN);
|
||||
break;
|
||||
default:
|
||||
PL_strncpy(fmtD, "", NSDATETIME_FORMAT_BUFFER_LEN);
|
||||
}
|
||||
|
||||
// set time format
|
||||
switch (timeFormatSelector) {
|
||||
case kTimeFormatNone:
|
||||
PL_strncpy(fmtT, "", NSDATETIME_FORMAT_BUFFER_LEN);
|
||||
break;
|
||||
case kTimeFormatSeconds:
|
||||
PL_strncpy(fmtT, "%X", NSDATETIME_FORMAT_BUFFER_LEN);
|
||||
break;
|
||||
case kTimeFormatNoSeconds:
|
||||
PL_strncpy(fmtT,
|
||||
mLocalePreferred24hour ? "%H:%M" : mLocaleAMPMfirst ? "%p %I:%M" : "%I:%M %p",
|
||||
NSDATETIME_FORMAT_BUFFER_LEN);
|
||||
break;
|
||||
case kTimeFormatSecondsForce24Hour:
|
||||
PL_strncpy(fmtT, "%H:%M:%S", NSDATETIME_FORMAT_BUFFER_LEN);
|
||||
break;
|
||||
case kTimeFormatNoSecondsForce24Hour:
|
||||
PL_strncpy(fmtT, "%H:%M", NSDATETIME_FORMAT_BUFFER_LEN);
|
||||
break;
|
||||
default:
|
||||
PL_strncpy(fmtT, "", NSDATETIME_FORMAT_BUFFER_LEN);
|
||||
}
|
||||
}
|
||||
|
||||
// generate data/time string
|
||||
char *old_locale = setlocale(LC_TIME, nullptr);
|
||||
(void) setlocale(LC_TIME, mPlatformLocale.get());
|
||||
if (strlen(fmtD) && strlen(fmtT)) {
|
||||
PL_strncat(fmtD, " ", NSDATETIME_FORMAT_BUFFER_LEN);
|
||||
PL_strncat(fmtD, fmtT, NSDATETIME_FORMAT_BUFFER_LEN);
|
||||
strftime(strOut, NSDATETIME_FORMAT_BUFFER_LEN, fmtD, tmTime);
|
||||
}
|
||||
else if (strlen(fmtD) && !strlen(fmtT)) {
|
||||
strftime(strOut, NSDATETIME_FORMAT_BUFFER_LEN, fmtD, tmTime);
|
||||
}
|
||||
else if (!strlen(fmtD) && strlen(fmtT)) {
|
||||
strftime(strOut, NSDATETIME_FORMAT_BUFFER_LEN, fmtT, tmTime);
|
||||
}
|
||||
else {
|
||||
PL_strncpy(strOut, "", NSDATETIME_FORMAT_BUFFER_LEN);
|
||||
}
|
||||
(void) setlocale(LC_TIME, old_locale);
|
||||
|
||||
// convert result to unicode
|
||||
int32_t srcLength = (int32_t) strlen(strOut);
|
||||
int32_t unicharLength = NSDATETIME_FORMAT_BUFFER_LEN*2;
|
||||
char16_t unichars[NSDATETIME_FORMAT_BUFFER_LEN*2]; // buffer for date and time
|
||||
|
||||
rv = mDecoder->Convert(strOut, &srcLength, unichars, &unicharLength);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
stringOut.Assign(unichars, unicharLength);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
// performs a locale sensitive date formatting operation on the PRTime parameter
|
||||
nsresult nsDateTimeFormatUnix::FormatPRTime(nsILocale* locale,
|
||||
const nsDateFormatSelector dateFormatSelector,
|
||||
const nsTimeFormatSelector timeFormatSelector,
|
||||
const PRTime prTime,
|
||||
nsAString& stringOut)
|
||||
{
|
||||
PRExplodedTime explodedTime;
|
||||
PR_ExplodeTime(prTime, PR_LocalTimeParameters, &explodedTime);
|
||||
|
||||
return FormatPRExplodedTime(locale, dateFormatSelector, timeFormatSelector, &explodedTime, stringOut);
|
||||
}
|
||||
|
||||
// performs a locale sensitive date formatting operation on the PRExplodedTime parameter
|
||||
nsresult nsDateTimeFormatUnix::FormatPRExplodedTime(nsILocale* locale,
|
||||
const nsDateFormatSelector dateFormatSelector,
|
||||
const nsTimeFormatSelector timeFormatSelector,
|
||||
const PRExplodedTime* explodedTime,
|
||||
nsAString& stringOut)
|
||||
{
|
||||
struct tm tmTime;
|
||||
/* be safe and set all members of struct tm to zero
|
||||
*
|
||||
* there are other fields in the tm struct that we aren't setting
|
||||
* (tm_isdst, tm_gmtoff, tm_zone, should we set these?) and since
|
||||
* tmTime is on the stack, it may be filled with garbage, but
|
||||
* the garbage may vary. (this may explain why some saw bug #10412, and
|
||||
* others did not.
|
||||
*
|
||||
* when tmTime is passed to strftime() with garbage bad things may happen.
|
||||
* see bug #10412
|
||||
*/
|
||||
memset( &tmTime, 0, sizeof(tmTime) );
|
||||
|
||||
tmTime.tm_yday = explodedTime->tm_yday;
|
||||
tmTime.tm_wday = explodedTime->tm_wday;
|
||||
tmTime.tm_year = explodedTime->tm_year;
|
||||
tmTime.tm_year -= 1900;
|
||||
tmTime.tm_mon = explodedTime->tm_month;
|
||||
tmTime.tm_mday = explodedTime->tm_mday;
|
||||
tmTime.tm_hour = explodedTime->tm_hour;
|
||||
tmTime.tm_min = explodedTime->tm_min;
|
||||
tmTime.tm_sec = explodedTime->tm_sec;
|
||||
|
||||
return FormatTMTime(locale, dateFormatSelector, timeFormatSelector, &tmTime, stringOut);
|
||||
}
|
||||
|
|
@ -1,70 +0,0 @@
|
|||
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
#ifndef nsDateTimeFormatUnix_h__
|
||||
#define nsDateTimeFormatUnix_h__
|
||||
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIDateTimeFormat.h"
|
||||
#include "nsIUnicodeDecoder.h"
|
||||
|
||||
#define kPlatformLocaleLength 64
|
||||
|
||||
class nsDateTimeFormatUnix : public nsIDateTimeFormat {
|
||||
|
||||
public:
|
||||
NS_DECL_THREADSAFE_ISUPPORTS
|
||||
|
||||
// performs a locale sensitive date formatting operation on the time_t parameter
|
||||
NS_IMETHOD FormatTime(nsILocale* locale,
|
||||
const nsDateFormatSelector dateFormatSelector,
|
||||
const nsTimeFormatSelector timeFormatSelector,
|
||||
const time_t timetTime,
|
||||
nsAString& stringOut) override;
|
||||
|
||||
// performs a locale sensitive date formatting operation on the struct tm parameter
|
||||
NS_IMETHOD FormatTMTime(nsILocale* locale,
|
||||
const nsDateFormatSelector dateFormatSelector,
|
||||
const nsTimeFormatSelector timeFormatSelector,
|
||||
const struct tm* tmTime,
|
||||
nsAString& stringOut) override;
|
||||
|
||||
// performs a locale sensitive date formatting operation on the PRTime parameter
|
||||
NS_IMETHOD FormatPRTime(nsILocale* locale,
|
||||
const nsDateFormatSelector dateFormatSelector,
|
||||
const nsTimeFormatSelector timeFormatSelector,
|
||||
const PRTime prTime,
|
||||
nsAString& stringOut) override;
|
||||
|
||||
// performs a locale sensitive date formatting operation on the PRExplodedTime parameter
|
||||
NS_IMETHOD FormatPRExplodedTime(nsILocale* locale,
|
||||
const nsDateFormatSelector dateFormatSelector,
|
||||
const nsTimeFormatSelector timeFormatSelector,
|
||||
const PRExplodedTime* explodedTime,
|
||||
nsAString& stringOut) override;
|
||||
|
||||
|
||||
nsDateTimeFormatUnix() {mLocale.Truncate();mAppLocale.Truncate();}
|
||||
|
||||
private:
|
||||
virtual ~nsDateTimeFormatUnix() {}
|
||||
|
||||
// init this interface to a specified locale
|
||||
NS_IMETHOD Initialize(nsILocale* locale);
|
||||
|
||||
void LocalePreferred24hour();
|
||||
|
||||
nsString mLocale;
|
||||
nsString mAppLocale;
|
||||
nsCString mCharset; // in order to convert API result to unicode
|
||||
nsCString mPlatformLocale; // for setlocale
|
||||
bool mLocalePreferred24hour; // true if 24 hour format is preferred by current locale
|
||||
bool mLocaleAMPMfirst; // true if AM/PM string is preferred before the time
|
||||
nsCOMPtr <nsIUnicodeDecoder> mDecoder;
|
||||
};
|
||||
|
||||
#endif /* nsDateTimeFormatUnix_h__ */
|
|
@ -6,7 +6,6 @@
|
|||
|
||||
SOURCES += [
|
||||
'nsCollationWin.cpp',
|
||||
'nsDateTimeFormatWin.cpp',
|
||||
'nsWin32Locale.cpp',
|
||||
'nsWinCharset.cpp',
|
||||
]
|
||||
|
|
|
@ -1,253 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "nsDateTimeFormatWin.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsILocaleService.h"
|
||||
#include "nsWin32Locale.h"
|
||||
#include "nsUnicharUtils.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
|
||||
#define NSDATETIMEFORMAT_BUFFER_LEN 80
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsDateTimeFormatWin, nsIDateTimeFormat)
|
||||
|
||||
|
||||
// init this interface to a specified locale
|
||||
nsresult nsDateTimeFormatWin::Initialize(nsILocale* locale)
|
||||
{
|
||||
nsAutoString localeStr;
|
||||
nsresult res = NS_OK;
|
||||
|
||||
// use cached info if match with stored locale
|
||||
if (!locale) {
|
||||
if (!mLocale.IsEmpty() &&
|
||||
mLocale.Equals(mAppLocale, nsCaseInsensitiveStringComparator())) {
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
else {
|
||||
res = locale->GetCategory(NS_LITERAL_STRING("NSILOCALE_TIME"), localeStr);
|
||||
if (NS_SUCCEEDED(res) && !localeStr.IsEmpty()) {
|
||||
if (!mLocale.IsEmpty() &&
|
||||
mLocale.Equals(localeStr, nsCaseInsensitiveStringComparator())) {
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// default LCID (en-US)
|
||||
mLCID = 1033;
|
||||
|
||||
// get locale string, use app default if no locale specified
|
||||
if (!locale) {
|
||||
nsCOMPtr<nsILocaleService> localeService =
|
||||
do_GetService(NS_LOCALESERVICE_CONTRACTID);
|
||||
if (localeService) {
|
||||
nsCOMPtr<nsILocale> appLocale;
|
||||
res = localeService->GetApplicationLocale(getter_AddRefs(appLocale));
|
||||
if (NS_SUCCEEDED(res)) {
|
||||
res = appLocale->GetCategory(NS_LITERAL_STRING("NSILOCALE_TIME"),
|
||||
localeStr);
|
||||
if (NS_SUCCEEDED(res) && !localeStr.IsEmpty()) {
|
||||
mAppLocale.Assign(localeStr); // cache app locale name
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
res = locale->GetCategory(NS_LITERAL_STRING("NSILOCALE_TIME"), localeStr);
|
||||
}
|
||||
|
||||
// Get LCID and charset name from locale, if available
|
||||
if (NS_SUCCEEDED(res) && !localeStr.IsEmpty()) {
|
||||
mLocale.Assign(localeStr); // cache locale name
|
||||
res = nsWin32Locale::GetPlatformLocale(mLocale, (LCID *) &mLCID);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
// performs a locale sensitive date formatting operation on the time_t parameter
|
||||
nsresult nsDateTimeFormatWin::FormatTime(nsILocale* locale,
|
||||
const nsDateFormatSelector dateFormatSelector,
|
||||
const nsTimeFormatSelector timeFormatSelector,
|
||||
const time_t timetTime,
|
||||
nsAString& stringOut)
|
||||
{
|
||||
return FormatTMTime(locale, dateFormatSelector, timeFormatSelector, localtime( &timetTime ), stringOut);
|
||||
}
|
||||
|
||||
// performs a locale sensitive date formatting operation on the struct tm parameter
|
||||
nsresult nsDateTimeFormatWin::FormatTMTime(nsILocale* locale,
|
||||
const nsDateFormatSelector dateFormatSelector,
|
||||
const nsTimeFormatSelector timeFormatSelector,
|
||||
const struct tm* tmTime,
|
||||
nsAString& stringOut)
|
||||
{
|
||||
SYSTEMTIME system_time;
|
||||
DWORD dwFlags_Date = 0, dwFlags_Time = 0;
|
||||
int dateLen, timeLen;
|
||||
char16_t dateBuffer[NSDATETIMEFORMAT_BUFFER_LEN], timeBuffer[NSDATETIMEFORMAT_BUFFER_LEN];
|
||||
|
||||
// set up locale data
|
||||
(void) Initialize(locale);
|
||||
|
||||
// Map tm to SYSTEMTIME
|
||||
system_time.wYear = 1900 + tmTime->tm_year;
|
||||
system_time.wMonth = tmTime->tm_mon + 1;
|
||||
system_time.wDayOfWeek = tmTime->tm_wday;
|
||||
system_time.wDay = tmTime->tm_mday;
|
||||
system_time.wHour = tmTime->tm_hour;
|
||||
system_time.wMinute = tmTime->tm_min;
|
||||
system_time.wSecond = tmTime->tm_sec;
|
||||
system_time.wMilliseconds = 0;
|
||||
|
||||
// Map to WinAPI date format
|
||||
switch (dateFormatSelector) {
|
||||
case kDateFormatLong:
|
||||
dwFlags_Date = DATE_LONGDATE;
|
||||
break;
|
||||
case kDateFormatShort:
|
||||
dwFlags_Date = DATE_SHORTDATE;
|
||||
break;
|
||||
case kDateFormatWeekday:
|
||||
dwFlags_Date = 0;
|
||||
break;
|
||||
case kDateFormatYearMonth:
|
||||
dwFlags_Date = 0; // TODO:only availabe NT5
|
||||
break;
|
||||
}
|
||||
|
||||
// Map to WinAPI time format
|
||||
switch (timeFormatSelector) {
|
||||
case kTimeFormatSeconds:
|
||||
dwFlags_Time = 0;
|
||||
break;
|
||||
case kTimeFormatNoSeconds:
|
||||
dwFlags_Time = TIME_NOSECONDS;
|
||||
break;
|
||||
case kTimeFormatSecondsForce24Hour:
|
||||
dwFlags_Time = TIME_FORCE24HOURFORMAT;
|
||||
break;
|
||||
case kTimeFormatNoSecondsForce24Hour:
|
||||
dwFlags_Time = TIME_NOSECONDS + TIME_FORCE24HOURFORMAT;
|
||||
break;
|
||||
}
|
||||
|
||||
// Call GetDateFormatW
|
||||
if (dateFormatSelector == kDateFormatNone) {
|
||||
dateLen = 0;
|
||||
}
|
||||
else {
|
||||
if (dateFormatSelector == kDateFormatYearMonth) {
|
||||
dateLen = nsGetDateFormatW(0, &system_time, "yyyy/MM",
|
||||
dateBuffer, NSDATETIMEFORMAT_BUFFER_LEN);
|
||||
}
|
||||
else if (dateFormatSelector == kDateFormatWeekday) {
|
||||
dateLen = nsGetDateFormatW(0, &system_time, "ddd",
|
||||
dateBuffer, NSDATETIMEFORMAT_BUFFER_LEN);
|
||||
}
|
||||
else {
|
||||
dateLen = nsGetDateFormatW(dwFlags_Date, &system_time, nullptr,
|
||||
dateBuffer, NSDATETIMEFORMAT_BUFFER_LEN);
|
||||
}
|
||||
if (dateLen != 0) {
|
||||
dateLen--; // Since the count includes the terminating null.
|
||||
}
|
||||
}
|
||||
|
||||
// Call GetTimeFormatW
|
||||
if (timeFormatSelector == kTimeFormatNone) {
|
||||
timeLen = 0;
|
||||
}
|
||||
else {
|
||||
timeLen = nsGetTimeFormatW(dwFlags_Time, &system_time, nullptr,
|
||||
timeBuffer, NSDATETIMEFORMAT_BUFFER_LEN);
|
||||
if (timeLen != 0) {
|
||||
timeLen--; // Since the count includes the terminating null.
|
||||
}
|
||||
}
|
||||
|
||||
NS_ASSERTION(NSDATETIMEFORMAT_BUFFER_LEN >= (uint32_t) (dateLen + 1), "internal date buffer is not large enough");
|
||||
NS_ASSERTION(NSDATETIMEFORMAT_BUFFER_LEN >= (uint32_t) (timeLen + 1), "internal time buffer is not large enough");
|
||||
|
||||
// Copy the result
|
||||
stringOut.Truncate();
|
||||
if (dateLen != 0 && timeLen != 0) {
|
||||
stringOut.Assign(dateBuffer, dateLen);
|
||||
stringOut.Append((char16_t *)(L" "), 1);
|
||||
stringOut.Append(timeBuffer, timeLen);
|
||||
}
|
||||
else if (dateLen != 0 && timeLen == 0) {
|
||||
stringOut.Assign(dateBuffer, dateLen);
|
||||
}
|
||||
else if (dateLen == 0 && timeLen != 0) {
|
||||
stringOut.Assign(timeBuffer, timeLen);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// performs a locale sensitive date formatting operation on the PRTime parameter
|
||||
nsresult nsDateTimeFormatWin::FormatPRTime(nsILocale* locale,
|
||||
const nsDateFormatSelector dateFormatSelector,
|
||||
const nsTimeFormatSelector timeFormatSelector,
|
||||
const PRTime prTime,
|
||||
nsAString& stringOut)
|
||||
{
|
||||
PRExplodedTime explodedTime;
|
||||
PR_ExplodeTime(prTime, PR_LocalTimeParameters, &explodedTime);
|
||||
|
||||
return FormatPRExplodedTime(locale, dateFormatSelector, timeFormatSelector, &explodedTime, stringOut);
|
||||
}
|
||||
|
||||
// performs a locale sensitive date formatting operation on the PRExplodedTime parameter
|
||||
nsresult nsDateTimeFormatWin::FormatPRExplodedTime(nsILocale* locale,
|
||||
const nsDateFormatSelector dateFormatSelector,
|
||||
const nsTimeFormatSelector timeFormatSelector,
|
||||
const PRExplodedTime* explodedTime,
|
||||
nsAString& stringOut)
|
||||
{
|
||||
struct tm tmTime;
|
||||
memset( &tmTime, 0, sizeof(tmTime) );
|
||||
|
||||
tmTime.tm_yday = explodedTime->tm_yday;
|
||||
tmTime.tm_wday = explodedTime->tm_wday;
|
||||
tmTime.tm_year = explodedTime->tm_year;
|
||||
tmTime.tm_year -= 1900;
|
||||
tmTime.tm_mon = explodedTime->tm_month;
|
||||
tmTime.tm_mday = explodedTime->tm_mday;
|
||||
tmTime.tm_hour = explodedTime->tm_hour;
|
||||
tmTime.tm_min = explodedTime->tm_min;
|
||||
tmTime.tm_sec = explodedTime->tm_sec;
|
||||
|
||||
return FormatTMTime(locale, dateFormatSelector, timeFormatSelector, &tmTime, stringOut);
|
||||
}
|
||||
|
||||
int nsDateTimeFormatWin::nsGetTimeFormatW(DWORD dwFlags, const SYSTEMTIME *lpTime,
|
||||
const char* format, char16_t *timeStr, int cchTime)
|
||||
{
|
||||
int len = 0;
|
||||
len = GetTimeFormatW(mLCID, dwFlags, lpTime,
|
||||
format ?
|
||||
NS_ConvertASCIItoUTF16(format).get() :
|
||||
nullptr,
|
||||
(LPWSTR) timeStr, cchTime);
|
||||
return len;
|
||||
}
|
||||
|
||||
int nsDateTimeFormatWin::nsGetDateFormatW(DWORD dwFlags, const SYSTEMTIME *lpDate,
|
||||
const char* format, char16_t *dateStr, int cchDate)
|
||||
{
|
||||
int len = 0;
|
||||
len = GetDateFormatW(mLCID, dwFlags, lpDate,
|
||||
format ? NS_ConvertASCIItoUTF16(format).get() : nullptr,
|
||||
(LPWSTR) dateStr, cchDate);
|
||||
return len;
|
||||
}
|
|
@ -1,71 +0,0 @@
|
|||
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
#ifndef nsDateTimeFormatWin_h__
|
||||
#define nsDateTimeFormatWin_h__
|
||||
|
||||
|
||||
#include "nsIDateTimeFormat.h"
|
||||
#include <windows.h>
|
||||
|
||||
|
||||
// Locale sensitive date and time format interface
|
||||
//
|
||||
class nsDateTimeFormatWin : public nsIDateTimeFormat {
|
||||
virtual ~nsDateTimeFormatWin() {}
|
||||
|
||||
public:
|
||||
NS_DECL_THREADSAFE_ISUPPORTS
|
||||
|
||||
// performs a locale sensitive date formatting operation on the time_t parameter
|
||||
NS_IMETHOD FormatTime(nsILocale* locale,
|
||||
const nsDateFormatSelector dateFormatSelector,
|
||||
const nsTimeFormatSelector timeFormatSelector,
|
||||
const time_t timetTime,
|
||||
nsAString& stringOut);
|
||||
|
||||
// performs a locale sensitive date formatting operation on the struct tm parameter
|
||||
NS_IMETHOD FormatTMTime(nsILocale* locale,
|
||||
const nsDateFormatSelector dateFormatSelector,
|
||||
const nsTimeFormatSelector timeFormatSelector,
|
||||
const struct tm* tmTime,
|
||||
nsAString& stringOut);
|
||||
|
||||
// performs a locale sensitive date formatting operation on the PRTime parameter
|
||||
NS_IMETHOD FormatPRTime(nsILocale* locale,
|
||||
const nsDateFormatSelector dateFormatSelector,
|
||||
const nsTimeFormatSelector timeFormatSelector,
|
||||
const PRTime prTime,
|
||||
nsAString& stringOut);
|
||||
|
||||
// performs a locale sensitive date formatting operation on the PRExplodedTime parameter
|
||||
NS_IMETHOD FormatPRExplodedTime(nsILocale* locale,
|
||||
const nsDateFormatSelector dateFormatSelector,
|
||||
const nsTimeFormatSelector timeFormatSelector,
|
||||
const PRExplodedTime* explodedTime,
|
||||
nsAString& stringOut);
|
||||
|
||||
nsDateTimeFormatWin() {mLocale.SetLength(0);mAppLocale.SetLength(0);}
|
||||
|
||||
|
||||
private:
|
||||
// init this interface to a specified locale
|
||||
NS_IMETHOD Initialize(nsILocale* locale);
|
||||
|
||||
// call GetTimeFormatW or TimeFormatA
|
||||
int nsGetTimeFormatW(DWORD dwFlags, const SYSTEMTIME *lpTime,
|
||||
const char* format, char16_t *timeStr, int cchTime);
|
||||
|
||||
// call GetDateFormatW or GetDateFormatA
|
||||
int nsGetDateFormatW(DWORD dwFlags, const SYSTEMTIME *lpDate,
|
||||
const char* format, char16_t *dateStr, int cchDate);
|
||||
|
||||
nsString mLocale;
|
||||
nsString mAppLocale;
|
||||
uint32_t mLCID; // Windows platform locale ID
|
||||
};
|
||||
|
||||
#endif /* nsDateTimeFormatWin_h__ */
|
|
@ -4721,6 +4721,15 @@ nsCSSFrameConstructor::FindDisplayData(const nsStyleDisplay* aDisplay,
|
|||
&nsCSSFrameConstructor::ConstructScrollableBlock) };
|
||||
return &sScrollableBlockData[caption];
|
||||
}
|
||||
|
||||
// If the scrollable frame would have propagated its scrolling to the
|
||||
// viewport, we still want to construct a regular block rather than a
|
||||
// scrollframe so that it paginates correctly, but we don't want to set
|
||||
// the bit on the block that tells it to clip at paint time.
|
||||
if (mPresShell->GetPresContext()->
|
||||
ElementWouldPropagateScrollbarStyles(aElement)) {
|
||||
suppressScrollFrame = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Handle various non-scrollable blocks.
|
||||
|
|
|
@ -1365,15 +1365,6 @@ static nsIContent*
|
|||
GetPropagatedScrollbarStylesForViewport(nsPresContext* aPresContext,
|
||||
ScrollbarStyles *aStyles)
|
||||
{
|
||||
// Set default
|
||||
*aStyles = ScrollbarStyles(NS_STYLE_OVERFLOW_AUTO, NS_STYLE_OVERFLOW_AUTO);
|
||||
|
||||
// We never mess with the viewport scroll state
|
||||
// when printing or in print preview
|
||||
if (aPresContext->IsPaginated()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsIDocument* document = aPresContext->Document();
|
||||
Element* docElement = document->GetRootElement();
|
||||
|
||||
|
@ -1430,8 +1421,15 @@ GetPropagatedScrollbarStylesForViewport(nsPresContext* aPresContext,
|
|||
nsIContent*
|
||||
nsPresContext::UpdateViewportScrollbarStylesOverride()
|
||||
{
|
||||
nsIContent* propagatedFrom =
|
||||
// Start off with our default styles, and then update them as needed.
|
||||
mViewportStyleScrollbar = ScrollbarStyles(NS_STYLE_OVERFLOW_AUTO,
|
||||
NS_STYLE_OVERFLOW_AUTO);
|
||||
nsIContent* propagatedFrom = nullptr;
|
||||
// Don't propagate the scrollbar state in printing or print preview.
|
||||
if (!IsPaginated()) {
|
||||
propagatedFrom =
|
||||
GetPropagatedScrollbarStylesForViewport(this, &mViewportStyleScrollbar);
|
||||
}
|
||||
|
||||
nsIDocument* document = Document();
|
||||
if (Element* fullscreenElement = document->GetFullscreenElement()) {
|
||||
|
@ -1450,6 +1448,24 @@ nsPresContext::UpdateViewportScrollbarStylesOverride()
|
|||
return propagatedFrom;
|
||||
}
|
||||
|
||||
bool
|
||||
nsPresContext::ElementWouldPropagateScrollbarStyles(Element* aElement)
|
||||
{
|
||||
MOZ_ASSERT(IsPaginated(), "Should only be called on paginated contexts");
|
||||
if (aElement->GetParent() && !aElement->IsHTMLElement(nsGkAtoms::body)) {
|
||||
// We certainly won't be propagating from this element.
|
||||
return false;
|
||||
}
|
||||
|
||||
// Go ahead and just call GetPropagatedScrollbarStylesForViewport, but update
|
||||
// a dummy ScrollbarStyles we don't care about. It'll do a bit of extra work,
|
||||
// but saves us having to have more complicated code or more code duplication;
|
||||
// in practice we will make this call quite rarely, because we checked for all
|
||||
// the common cases above.
|
||||
ScrollbarStyles dummy(NS_STYLE_OVERFLOW_AUTO, NS_STYLE_OVERFLOW_AUTO);
|
||||
return GetPropagatedScrollbarStylesForViewport(this, &dummy) == aElement;
|
||||
}
|
||||
|
||||
void
|
||||
nsPresContext::SetContainer(nsIDocShell* aDocShell)
|
||||
{
|
||||
|
|
|
@ -77,6 +77,9 @@ namespace layers {
|
|||
class ContainerLayer;
|
||||
class LayerManager;
|
||||
} // namespace layers
|
||||
namespace dom {
|
||||
class Element;
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
// supported values for cached bool types
|
||||
|
@ -721,6 +724,12 @@ public:
|
|||
return mViewportStyleScrollbar;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether the given element would propagate its scrollbar styles to the
|
||||
* viewport in non-paginated mode. Must only be called if IsPaginated().
|
||||
*/
|
||||
bool ElementWouldPropagateScrollbarStyles(mozilla::dom::Element* aElement);
|
||||
|
||||
/**
|
||||
* Set and get methods for controlling the background drawing
|
||||
*/
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include "nsLayoutStatics.h"
|
||||
#include "nscore.h"
|
||||
|
||||
#include "DateTimeFormat.h"
|
||||
#include "nsAttrValue.h"
|
||||
#include "nsAutoCopyListener.h"
|
||||
#include "nsColorNames.h"
|
||||
|
@ -423,6 +424,8 @@ nsLayoutStatics::Shutdown()
|
|||
nsHyphenationManager::Shutdown();
|
||||
nsDOMMutationObserver::Shutdown();
|
||||
|
||||
DateTimeFormat::Shutdown();
|
||||
|
||||
ContentParent::ShutDown();
|
||||
|
||||
DisplayItemClip::Shutdown();
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
#include "nsSimplePageSequenceFrame.h"
|
||||
|
||||
#include "DateTimeFormat.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsDeviceContext.h"
|
||||
#include "nsPresContext.h"
|
||||
|
@ -22,7 +23,6 @@
|
|||
#include "nsHTMLCanvasFrame.h"
|
||||
#include "mozilla/dom/HTMLCanvasElement.h"
|
||||
#include "nsICanvasRenderingContextInternal.h"
|
||||
#include "nsIDateTimeFormat.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include <algorithm>
|
||||
|
||||
|
@ -299,18 +299,10 @@ nsSimplePageSequenceFrame::Reflow(nsPresContext* aPresContext,
|
|||
pageNum++;
|
||||
}
|
||||
|
||||
// Create current Date/Time String
|
||||
if (!mDateFormatter) {
|
||||
mDateFormatter = nsIDateTimeFormat::Create();
|
||||
}
|
||||
if (!mDateFormatter) {
|
||||
return;
|
||||
}
|
||||
nsAutoString formattedDateString;
|
||||
time_t ltime;
|
||||
time( <ime );
|
||||
if (NS_SUCCEEDED(mDateFormatter->FormatTime(nullptr /* nsILocale* locale */,
|
||||
kDateFormatShort,
|
||||
if (NS_SUCCEEDED(DateTimeFormat::FormatTime(kDateFormatShort,
|
||||
kTimeFormatNoSeconds,
|
||||
ltime,
|
||||
formattedDateString))) {
|
||||
|
|
|
@ -10,8 +10,6 @@
|
|||
#include "nsContainerFrame.h"
|
||||
#include "nsIPrintSettings.h"
|
||||
|
||||
class nsIDateTimeFormat;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
|
@ -139,9 +137,6 @@ protected:
|
|||
|
||||
nsMargin mMargin;
|
||||
|
||||
// I18N date formatter service which we'll want to cache locally.
|
||||
nsCOMPtr<nsIDateTimeFormat> mDateFormatter;
|
||||
|
||||
nsSize mSize;
|
||||
nsSharedPageData* mPageData; // data shared by all the nsPageFrames
|
||||
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
<!DOCTYPE html>
|
||||
<html class="reftest-print" style="margin: 0; padding: 0">
|
||||
<body style="margin: 0; padding: 0">
|
||||
<div>
|
||||
<div style="height: 1.25in; border: 0.25in solid green"></div>
|
||||
<div style="height: 1.25in; border: 0.25in solid green"></div>
|
||||
<div style="height: 1.25in; border: 0.25in solid green; border-bottom: none"></div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
<!DOCTYPE html>
|
||||
<html class="reftest-print" style="margin: 0; padding: 0;">
|
||||
<body style="overflow: scroll; height: 5in; margin: 0; padding: 0;">
|
||||
<body style="margin: 0; padding: 0;">
|
||||
<div style="overflow: scroll; height: 5in;">
|
||||
<div style="height: 1.25in; border: 0.25in solid green"></div>
|
||||
<div style="height: 1.25in; border: 0.25in solid green"></div>
|
||||
<div style="height: 1.25in; border: 0.25in solid green"></div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
<!DOCTYPE html>
|
||||
<html class="reftest-print" style="margin: 0; padding: 0;">
|
||||
<body style="overflow: -moz-hidden-unscrollable; height: 5in; margin: 0; padding: 0;">
|
||||
<body style="margin: 0; padding: 0;">
|
||||
<div style="overflow: -moz-hidden-unscrollable; height: 5in;">
|
||||
<div style="height: 1.25in; border: 0.25in solid green"></div>
|
||||
<div style="height: 1.25in; border: 0.25in solid green"></div>
|
||||
<div style="height: 1.25in; border: 0.25in solid green"></div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
<!DOCTYPE html>
|
||||
<html class="reftest-print" style="margin: 0; padding: 0; overflow: hidden">
|
||||
<body style="margin: 0; padding: 0; overflow: scroll; height: 5in">
|
||||
<div>
|
||||
<div style="height: 1.25in; border: 0.25in solid green"></div>
|
||||
<div style="height: 1.25in; border: 0.25in solid green"></div>
|
||||
<div style="height: 1.25in; border: 0.25in solid green"></div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,10 @@
|
|||
<!DOCTYPE html>
|
||||
<html class="reftest-print" style="margin: 0; padding: 0; overflow: hidden">
|
||||
<body style="margin: 0; padding: 0; overflow: -moz-hidden-unscrollable; height: 5in;">
|
||||
<div>
|
||||
<div style="height: 1.25in; border: 0.25in solid green"></div>
|
||||
<div style="height: 1.25in; border: 0.25in solid green"></div>
|
||||
<div style="height: 1.25in; border: 0.25in solid green"></div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,10 @@
|
|||
<!DOCTYPE html>
|
||||
<html class="reftest-print" style="margin: 0; padding: 0;">
|
||||
<body style="margin: 0; padding: 0; overflow: -moz-hidden-unscrollable; height: 5in;">
|
||||
<div>
|
||||
<div style="height: 1.25in; border: 0.25in solid green"></div>
|
||||
<div style="height: 1.25in; border: 0.25in solid green"></div>
|
||||
<div style="height: 1.25in; border: 0.25in solid green"></div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,10 @@
|
|||
<!DOCTYPE html>
|
||||
<html class="reftest-print" style="margin: 0; padding: 0">
|
||||
<body style="margin: 0; padding: 0">
|
||||
<div>
|
||||
<div style="height: 1.25in; border: 0.25in solid green"></div>
|
||||
<div style="height: 1.25in; border: 0.25in solid green"></div>
|
||||
<div style="height: 1.25in; border: 0.25in solid green;"></div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,10 @@
|
|||
<!DOCTYPE html>
|
||||
<html class="reftest-print" style="margin: 0; padding: 0;">
|
||||
<body style="margin: 0; padding: 0; overflow: scroll; height: 5in">
|
||||
<div>
|
||||
<div style="height: 1.25in; border: 0.25in solid green"></div>
|
||||
<div style="height: 1.25in; border: 0.25in solid green"></div>
|
||||
<div style="height: 1.25in; border: 0.25in solid green"></div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
|
@ -9,6 +9,9 @@
|
|||
== test-async-print.html 272830-1-ref.html
|
||||
== 129941-1a.html 129941-1-ref.html
|
||||
== 129941-1b.html 129941-1-ref.html
|
||||
== 129941-1c.html 129941-1-ref.html
|
||||
== 129941-1d.html 129941-1-ref.html
|
||||
== 129941-1e.html 129941-1-ref.html
|
||||
== 609227-1.html 609227-1-ref.html
|
||||
== 609227-2a.html 609227-2-ref.html
|
||||
== 609227-2b.html 609227-2-ref.html
|
||||
|
@ -33,3 +36,4 @@ fuzzy-if(cocoaWidget,1,5000) == 745025-1.html 745025-1-ref.html
|
|||
== 966419-1.html 966419-1-ref.html
|
||||
== 966419-2.html 966419-2-ref.html
|
||||
# asserts(3) HTTP(..) fails 1108104.html 1108104-ref.html # bug 1067755, 1135556
|
||||
== 1321803-1a.html 1321803-1-ref.html
|
||||
|
|
|
@ -6,5 +6,7 @@
|
|||
<body>
|
||||
<p>This paragraph should have a green background.</p>
|
||||
<p>This paragraph should have a green background, too.</p>
|
||||
<p>@-moz-document rules should be applied.</p>
|
||||
<p>@-moz-document rules should not be applied.</p>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -1,10 +1,19 @@
|
|||
<!DOCTYPE html>
|
||||
<html class="reftest-wait">
|
||||
<head>
|
||||
<style>p { background-color: red; }</style>
|
||||
<style>
|
||||
p {
|
||||
background-color: red;
|
||||
}
|
||||
.reftest-xdomain {
|
||||
background: lime;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<p class="reftest-usercss">This paragraph should have a green background.</p>
|
||||
<p class="reftest-userxbl">This paragraph should have a green background, too.</p>
|
||||
<p class="reftest-domain">@-moz-document rules should be applied.</p>
|
||||
<p class="reftest-xdomain">@-moz-document rules should not be applied.</p>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -4,3 +4,17 @@
|
|||
.reftest-userxbl {
|
||||
-moz-binding: url("binding.xml#reftest-userxbl") !important;
|
||||
}
|
||||
/*
|
||||
* file: URLs have an empty domain.
|
||||
* Android uses special loopback-to-host address.
|
||||
*/
|
||||
@-moz-document domain(), domain(10.0.2.2) {
|
||||
.reftest-domain {
|
||||
background: lime !important;
|
||||
}
|
||||
}
|
||||
@-moz-document domain(example.invalid) {
|
||||
.reftest-xdomain {
|
||||
background: red !important;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,14 @@
|
|||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
UNIFIED_SOURCES += [
|
||||
# When built with --enable-debug, jemalloc4 makes headers define functions that
|
||||
# are normally inlined, and that prevents unified sources from working.
|
||||
if CONFIG['MOZ_DEBUG']:
|
||||
maybe_unified_sources = SOURCES
|
||||
else:
|
||||
maybe_unified_sources = UNIFIED_SOURCES
|
||||
|
||||
maybe_unified_sources += [
|
||||
'src/src/arena.c',
|
||||
'src/src/atomic.c',
|
||||
'src/src/base.c',
|
||||
|
@ -13,6 +20,7 @@ UNIFIED_SOURCES += [
|
|||
'src/src/chunk_dss.c',
|
||||
'src/src/chunk_mmap.c',
|
||||
'src/src/ckh.c',
|
||||
'src/src/ctl.c',
|
||||
'src/src/extent.c',
|
||||
'src/src/hash.c',
|
||||
'src/src/huge.c',
|
||||
|
@ -34,15 +42,10 @@ UNIFIED_SOURCES += [
|
|||
'src/src/witness.c',
|
||||
]
|
||||
|
||||
SOURCES += [
|
||||
# This file cannot be built in unified mode because of symbol clash on arena_purge.
|
||||
'src/src/ctl.c',
|
||||
]
|
||||
|
||||
# Only OSX needs the zone allocation implementation,
|
||||
# but only if replace-malloc is not enabled.
|
||||
if CONFIG['OS_TARGET'] == 'Darwin' and not CONFIG['MOZ_REPLACE_MALLOC']:
|
||||
UNIFIED_SOURCES += [
|
||||
maybe_unified_sources += [
|
||||
'src/src/zone.c',
|
||||
]
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "DateTimeFormat.h"
|
||||
#include "nsIndexedToHTML.h"
|
||||
#include "mozilla/dom/EncodingUtils.h"
|
||||
#include "nsNetUtil.h"
|
||||
|
@ -18,7 +19,6 @@
|
|||
#include "nsIPrefBranch.h"
|
||||
#include "nsIPrefLocalizedString.h"
|
||||
#include "nsIChromeRegistry.h"
|
||||
#include "nsIDateTimeFormat.h"
|
||||
#include "nsIStringBundle.h"
|
||||
#include "nsITextToSubURI.h"
|
||||
#include "nsXPIDLString.h"
|
||||
|
@ -69,10 +69,6 @@ nsIndexedToHTML::Init(nsIStreamListener* aListener) {
|
|||
|
||||
mListener = aListener;
|
||||
|
||||
mDateTime = nsIDateTimeFormat::Create();
|
||||
if (!mDateTime)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIStringBundleService> sbs =
|
||||
do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
@ -835,15 +831,13 @@ nsIndexedToHTML::OnIndexAvailable(nsIRequest *aRequest,
|
|||
pushBuffer.AppendInt(static_cast<int64_t>(t));
|
||||
pushBuffer.AppendLiteral("\">");
|
||||
nsAutoString formatted;
|
||||
mDateTime->FormatPRTime(nullptr,
|
||||
kDateFormatShort,
|
||||
mozilla::DateTimeFormat::FormatPRTime(kDateFormatShort,
|
||||
kTimeFormatNone,
|
||||
t,
|
||||
formatted);
|
||||
AppendNonAsciiToNCR(formatted, pushBuffer);
|
||||
pushBuffer.AppendLiteral("</td>\n <td>");
|
||||
mDateTime->FormatPRTime(nullptr,
|
||||
kDateFormatNone,
|
||||
mozilla::DateTimeFormat::FormatPRTime(kDateFormatNone,
|
||||
kTimeFormatSeconds,
|
||||
t,
|
||||
formatted);
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
#define NS_NSINDEXEDTOHTMLCONVERTER_CID \
|
||||
{ 0xcf0f71fd, 0xfafd, 0x4e2b, {0x9f, 0xdc, 0x13, 0x4d, 0x97, 0x2e, 0x16, 0xe2} }
|
||||
|
||||
class nsIDateTimeFormat;
|
||||
class nsIStringBundle;
|
||||
class nsITextToSubURI;
|
||||
|
||||
|
@ -47,7 +46,6 @@ protected:
|
|||
nsCOMPtr<nsIDirIndexParser> mParser;
|
||||
nsCOMPtr<nsIStreamListener> mListener; // final listener (consumer)
|
||||
|
||||
nsCOMPtr<nsIDateTimeFormat> mDateTime;
|
||||
nsCOMPtr<nsIStringBundle> mBundle;
|
||||
|
||||
nsCOMPtr<nsITextToSubURI> mTextToSubURI;
|
||||
|
|
|
@ -14,9 +14,6 @@
|
|||
#include "mozilla/Assertions.h"
|
||||
#include "mozilla/Casting.h"
|
||||
#include "mozilla/PodOperations.h"
|
||||
#ifdef ANDROID
|
||||
#include "nsPrintfCString.h"
|
||||
#endif
|
||||
#include "pk11pub.h"
|
||||
#include "pkix/pkixtypes.h"
|
||||
#include "prerror.h"
|
||||
|
@ -1251,22 +1248,6 @@ CertIsAuthoritativeForEVPolicy(const UniqueCERTCertificate& cert,
|
|||
return false;
|
||||
}
|
||||
|
||||
#ifdef ANDROID
|
||||
static char sCrashReasonBuffer[1024];
|
||||
|
||||
static void
|
||||
CrashWithReason(const char* messageFormat, const char* string,
|
||||
PRErrorCode errorCode)
|
||||
{
|
||||
nsPrintfCString assertionMessage(messageFormat, string, errorCode);
|
||||
mozilla::PodArrayZero(sCrashReasonBuffer);
|
||||
strncpy(sCrashReasonBuffer, assertionMessage.get(),
|
||||
sizeof(sCrashReasonBuffer));
|
||||
MOZ_CRASH_ANNOTATE(sCrashReasonBuffer);
|
||||
MOZ_REALLY_CRASH();
|
||||
}
|
||||
#endif
|
||||
|
||||
nsresult
|
||||
LoadExtendedValidationInfo()
|
||||
{
|
||||
|
@ -1276,18 +1257,10 @@ LoadExtendedValidationInfo()
|
|||
mozilla::ScopedAutoSECItem cabforumOIDItem;
|
||||
if (SEC_StringToOID(nullptr, &cabforumOIDItem, sCABForumOIDString, 0)
|
||||
!= SECSuccess) {
|
||||
#ifdef ANDROID
|
||||
CrashWithReason("SEC_StringToOID failed on '%s' with error '%d'",
|
||||
sCABForumOIDString, PR_GetError());
|
||||
#endif
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
sCABForumEVOIDTag = RegisterOID(cabforumOIDItem, sCABForumOIDDescription);
|
||||
if (sCABForumEVOIDTag == SEC_OID_UNKNOWN) {
|
||||
#ifdef ANDROID
|
||||
CrashWithReason("RegisterOID failed on '%s' with error '%d'",
|
||||
sCABForumOIDDescription, PR_GetError());
|
||||
#endif
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
@ -1352,18 +1325,10 @@ LoadExtendedValidationInfo()
|
|||
srv = SEC_StringToOID(nullptr, &evOIDItem, entry.dotted_oid, 0);
|
||||
MOZ_ASSERT(srv == SECSuccess, "SEC_StringToOID failed");
|
||||
if (srv != SECSuccess) {
|
||||
#ifdef ANDROID
|
||||
CrashWithReason("SEC_StringToOID failed on '%s' with error '%d'",
|
||||
entry.dotted_oid, PR_GetError());
|
||||
#endif
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
entry.oid_tag = RegisterOID(evOIDItem, entry.oid_name);
|
||||
if (entry.oid_tag == SEC_OID_UNKNOWN) {
|
||||
#ifdef ANDROID
|
||||
CrashWithReason("RegisterOID failed on '%s' with error '%d'",
|
||||
entry.oid_name, PR_GetError());
|
||||
#endif
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,12 +6,12 @@
|
|||
|
||||
#include "TransportSecurityInfo.h"
|
||||
|
||||
#include "DateTimeFormat.h"
|
||||
#include "PSMRunnable.h"
|
||||
#include "mozilla/Casting.h"
|
||||
#include "nsComponentManagerUtils.h"
|
||||
#include "nsIArray.h"
|
||||
#include "nsICertOverrideService.h"
|
||||
#include "nsIDateTimeFormat.h"
|
||||
#include "nsIObjectInputStream.h"
|
||||
#include "nsIObjectOutputStream.h"
|
||||
#include "nsIWebProgressListener.h"
|
||||
|
@ -798,14 +798,9 @@ GetDateBoundary(nsIX509Cert* ix509,
|
|||
trueExpired_falseNotYetValid = false;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDateTimeFormat> dateTimeFormat = nsIDateTimeFormat::Create();
|
||||
if (!dateTimeFormat) {
|
||||
return;
|
||||
}
|
||||
|
||||
dateTimeFormat->FormatPRTime(nullptr, kDateFormatLong, kTimeFormatNoSeconds,
|
||||
DateTimeFormat::FormatPRTime(kDateFormatLong, kTimeFormatNoSeconds,
|
||||
timeToUse, formattedDate);
|
||||
dateTimeFormat->FormatPRTime(nullptr, kDateFormatLong, kTimeFormatNoSeconds,
|
||||
DateTimeFormat::FormatPRTime(kDateFormatLong, kTimeFormatNoSeconds,
|
||||
now, nowDate);
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include <algorithm>
|
||||
|
||||
#include "DateTimeFormat.h"
|
||||
#include "ScopedNSSTypes.h"
|
||||
#include "mozilla/Casting.h"
|
||||
#include "mozilla/NotNull.h"
|
||||
|
@ -13,8 +14,6 @@
|
|||
#include "mozilla/UniquePtr.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsComponentManagerUtils.h"
|
||||
#include "nsDateTimeFormatCID.h"
|
||||
#include "nsIDateTimeFormat.h"
|
||||
#include "nsNSSASN1Object.h"
|
||||
#include "nsNSSCertTrust.h"
|
||||
#include "nsNSSCertValidity.h"
|
||||
|
@ -1614,18 +1613,13 @@ static nsresult
|
|||
ProcessTime(PRTime dispTime, const char16_t* displayName,
|
||||
nsIASN1Sequence* parentSequence)
|
||||
{
|
||||
nsCOMPtr<nsIDateTimeFormat> dateFormatter = nsIDateTimeFormat::Create();
|
||||
if (!dateFormatter) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsString text;
|
||||
nsString tempString;
|
||||
|
||||
PRExplodedTime explodedTime;
|
||||
PR_ExplodeTime(dispTime, PR_LocalTimeParameters, &explodedTime);
|
||||
|
||||
dateFormatter->FormatPRExplodedTime(nullptr, kDateFormatLong,
|
||||
DateTimeFormat::FormatPRExplodedTime(kDateFormatLong,
|
||||
kTimeFormatSeconds, &explodedTime,
|
||||
tempString);
|
||||
|
||||
|
@ -1635,7 +1629,7 @@ ProcessTime(PRTime dispTime, const char16_t* displayName,
|
|||
PRExplodedTime explodedTimeGMT;
|
||||
PR_ExplodeTime(dispTime, PR_GMTParameters, &explodedTimeGMT);
|
||||
|
||||
dateFormatter->FormatPRExplodedTime(nullptr, kDateFormatLong,
|
||||
DateTimeFormat::FormatPRExplodedTime(kDateFormatLong,
|
||||
kTimeFormatSeconds, &explodedTimeGMT,
|
||||
tempString);
|
||||
|
||||
|
|
|
@ -62,14 +62,9 @@ nsX509CertValidity::FormatTime(const PRTime& aTimeDate,
|
|||
if (!mTimesInitialized)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIDateTimeFormat> dateFormatter = nsIDateTimeFormat::Create();
|
||||
if (!dateFormatter) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
PRExplodedTime explodedTime;
|
||||
PR_ExplodeTime(const_cast<PRTime&>(aTimeDate), aParamFn, &explodedTime);
|
||||
return dateFormatter->FormatPRExplodedTime(nullptr, kDateFormatLong,
|
||||
return mozilla::DateTimeFormat::FormatPRExplodedTime(kDateFormatLong,
|
||||
aTimeFormatSelector,
|
||||
&explodedTime, aFormattedTimeDate);
|
||||
}
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
#ifndef nsNSSCertValidity_h
|
||||
#define nsNSSCertValidity_h
|
||||
|
||||
#include "DateTimeFormat.h"
|
||||
#include "ScopedNSSTypes.h"
|
||||
#include "nsIDateTimeFormat.h"
|
||||
#include "nsIX509CertValidity.h"
|
||||
#include "nsNSSShutDown.h"
|
||||
|
||||
|
|
|
@ -65,6 +65,11 @@
|
|||
#include "nsIWindowsRegKey.h"
|
||||
#endif
|
||||
|
||||
#ifdef ANDROID
|
||||
#include "mozilla/PodOperations.h"
|
||||
#include "nsPrintfCString.h"
|
||||
#endif // ANDROID
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::psm;
|
||||
|
||||
|
@ -1280,26 +1285,16 @@ nsNSSComponent::InitializePIPNSSBundle()
|
|||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIStringBundleService> bundleService(do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv));
|
||||
#ifdef ANDROID
|
||||
MOZ_RELEASE_ASSERT(NS_SUCCEEDED(rv));
|
||||
MOZ_RELEASE_ASSERT(bundleService);
|
||||
#endif
|
||||
if (NS_FAILED(rv) || !bundleService)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
bundleService->CreateBundle("chrome://pipnss/locale/pipnss.properties",
|
||||
getter_AddRefs(mPIPNSSBundle));
|
||||
#ifdef ANDROID
|
||||
MOZ_RELEASE_ASSERT(mPIPNSSBundle);
|
||||
#endif
|
||||
if (!mPIPNSSBundle)
|
||||
rv = NS_ERROR_FAILURE;
|
||||
|
||||
bundleService->CreateBundle("chrome://pipnss/locale/nsserrors.properties",
|
||||
getter_AddRefs(mNSSErrorsBundle));
|
||||
#ifdef ANDROID
|
||||
MOZ_RELEASE_ASSERT(mNSSErrorsBundle);
|
||||
#endif
|
||||
if (!mNSSErrorsBundle)
|
||||
rv = NS_ERROR_FAILURE;
|
||||
|
||||
|
@ -1449,9 +1444,6 @@ CipherSuiteChangeObserver::StartObserve()
|
|||
if (!sObserver) {
|
||||
RefPtr<CipherSuiteChangeObserver> observer = new CipherSuiteChangeObserver();
|
||||
nsresult rv = Preferences::AddStrongObserver(observer.get(), "security.");
|
||||
#ifdef ANDROID
|
||||
MOZ_RELEASE_ASSERT(NS_SUCCEEDED(rv));
|
||||
#endif
|
||||
if (NS_FAILED(rv)) {
|
||||
sObserver = nullptr;
|
||||
return rv;
|
||||
|
@ -1686,9 +1678,6 @@ GetNSSProfilePath(nsAutoCString& aProfilePath)
|
|||
rv = profileFileWin->GetNativeCanonicalPath(aProfilePath);
|
||||
#else
|
||||
rv = profileFile->GetNativePath(aProfilePath);
|
||||
#endif
|
||||
#ifdef ANDROID
|
||||
MOZ_RELEASE_ASSERT(NS_SUCCEEDED(rv));
|
||||
#endif
|
||||
if (NS_FAILED(rv)) {
|
||||
MOZ_LOG(gPIPNSSLog, LogLevel::Error,
|
||||
|
@ -1701,6 +1690,10 @@ GetNSSProfilePath(nsAutoCString& aProfilePath)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
#ifdef ANDROID
|
||||
static char sCrashReasonBuffer[1024];
|
||||
#endif // ANDROID
|
||||
|
||||
nsresult
|
||||
nsNSSComponent::InitializeNSS()
|
||||
{
|
||||
|
@ -1717,9 +1710,6 @@ nsNSSComponent::InitializeNSS()
|
|||
|
||||
MutexAutoLock lock(mutex);
|
||||
|
||||
#ifdef ANDROID
|
||||
MOZ_RELEASE_ASSERT(!mNSSInitialized);
|
||||
#endif
|
||||
if (mNSSInitialized) {
|
||||
// We should never try to initialize NSS more than once in a process.
|
||||
MOZ_ASSERT_UNREACHABLE("Trying to initialize NSS twice");
|
||||
|
@ -1738,9 +1728,6 @@ nsNSSComponent::InitializeNSS()
|
|||
|
||||
nsAutoCString profileStr;
|
||||
nsresult rv = GetNSSProfilePath(profileStr);
|
||||
#ifdef ANDROID
|
||||
MOZ_RELEASE_ASSERT(NS_SUCCEEDED(rv));
|
||||
#endif
|
||||
if (NS_FAILED(rv)) {
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
@ -1754,9 +1741,6 @@ nsNSSComponent::InitializeNSS()
|
|||
// modules will be loaded).
|
||||
if (runtime) {
|
||||
rv = runtime->GetInSafeMode(&inSafeMode);
|
||||
#ifdef ANDROID
|
||||
MOZ_RELEASE_ASSERT(NS_SUCCEEDED(rv));
|
||||
#endif
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
@ -1782,13 +1766,18 @@ nsNSSComponent::InitializeNSS()
|
|||
if (nocertdb || init_rv != SECSuccess) {
|
||||
init_rv = NSS_NoDB_Init(nullptr);
|
||||
#ifdef ANDROID
|
||||
MOZ_RELEASE_ASSERT(init_rv == SECSuccess);
|
||||
#endif
|
||||
if (init_rv != SECSuccess) {
|
||||
nsPrintfCString message("NSS_NoDB_Init failed with PRErrorCode %d",
|
||||
PR_GetError());
|
||||
mozilla::PodArrayZero(sCrashReasonBuffer);
|
||||
strncpy(sCrashReasonBuffer, message.get(),
|
||||
sizeof(sCrashReasonBuffer) - 1);
|
||||
MOZ_CRASH_ANNOTATE(sCrashReasonBuffer);
|
||||
MOZ_REALLY_CRASH();
|
||||
}
|
||||
#endif // ANDROID
|
||||
}
|
||||
if (init_rv != SECSuccess) {
|
||||
#ifdef ANDROID
|
||||
MOZ_RELEASE_ASSERT(false);
|
||||
#endif
|
||||
MOZ_LOG(gPIPNSSLog, LogLevel::Error, ("could not initialize NSS - panicking\n"));
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
@ -1810,9 +1799,6 @@ nsNSSComponent::InitializeNSS()
|
|||
SSL_OptionSetDefault(SSL_V2_COMPATIBLE_HELLO, false);
|
||||
|
||||
rv = setEnabledTLSVersions();
|
||||
#ifdef ANDROID
|
||||
MOZ_RELEASE_ASSERT(NS_SUCCEEDED(rv));
|
||||
#endif
|
||||
if (NS_FAILED(rv)) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
@ -1821,9 +1807,6 @@ nsNSSComponent::InitializeNSS()
|
|||
LoadLoadableRoots();
|
||||
|
||||
rv = LoadExtendedValidationInfo();
|
||||
#ifdef ANDROID
|
||||
MOZ_RELEASE_ASSERT(NS_SUCCEEDED(rv));
|
||||
#endif
|
||||
if (NS_FAILED(rv)) {
|
||||
MOZ_LOG(gPIPNSSLog, LogLevel::Error, ("failed to load EV info"));
|
||||
return rv;
|
||||
|
@ -1860,9 +1843,6 @@ nsNSSComponent::InitializeNSS()
|
|||
ENABLED_0RTT_DATA_DEFAULT));
|
||||
|
||||
if (NS_FAILED(InitializeCipherSuite())) {
|
||||
#ifdef ANDROID
|
||||
MOZ_RELEASE_ASSERT(false);
|
||||
#endif
|
||||
MOZ_LOG(gPIPNSSLog, LogLevel::Error, ("Unable to initialize cipher suite settings\n"));
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
@ -1875,17 +1855,11 @@ nsNSSComponent::InitializeNSS()
|
|||
// Note that this must occur before any calls to SSL_ClearSessionCache
|
||||
// (otherwise memory will leak).
|
||||
if (SSL_ConfigServerSessionIDCache(1000, 0, 0, nullptr) != SECSuccess) {
|
||||
#ifdef ANDROID
|
||||
MOZ_RELEASE_ASSERT(false);
|
||||
#endif
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// ensure the CertBlocklist is initialised
|
||||
nsCOMPtr<nsICertBlocklist> certList = do_GetService(NS_CERTBLOCKLIST_CONTRACTID);
|
||||
#ifdef ANDROID
|
||||
MOZ_RELEASE_ASSERT(certList);
|
||||
#endif
|
||||
if (!certList) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
@ -1902,9 +1876,6 @@ nsNSSComponent::InitializeNSS()
|
|||
// Initialize the site security service
|
||||
nsCOMPtr<nsISiteSecurityService> sssService =
|
||||
do_GetService(NS_SSSERVICE_CONTRACTID);
|
||||
#ifdef ANDROID
|
||||
MOZ_RELEASE_ASSERT(sssService);
|
||||
#endif
|
||||
if (!sssService) {
|
||||
MOZ_LOG(gPIPNSSLog, LogLevel::Debug, ("Cannot initialize site security service\n"));
|
||||
return NS_ERROR_FAILURE;
|
||||
|
@ -1913,9 +1884,6 @@ nsNSSComponent::InitializeNSS()
|
|||
// Initialize the cert override service
|
||||
nsCOMPtr<nsICertOverrideService> coService =
|
||||
do_GetService(NS_CERTOVERRIDE_CONTRACTID);
|
||||
#ifdef ANDROID
|
||||
MOZ_RELEASE_ASSERT(coService);
|
||||
#endif
|
||||
if (!coService) {
|
||||
MOZ_LOG(gPIPNSSLog, LogLevel::Debug, ("Cannot initialize cert override service\n"));
|
||||
return NS_ERROR_FAILURE;
|
||||
|
@ -1987,9 +1955,6 @@ nsNSSComponent::Init()
|
|||
MOZ_LOG(gPIPNSSLog, LogLevel::Debug, ("Beginning NSS initialization\n"));
|
||||
|
||||
rv = InitializePIPNSSBundle();
|
||||
#ifdef ANDROID
|
||||
MOZ_RELEASE_ASSERT(NS_SUCCEEDED(rv));
|
||||
#endif
|
||||
if (NS_FAILED(rv)) {
|
||||
MOZ_LOG(gPIPNSSLog, LogLevel::Error, ("Unable to create pipnss bundle.\n"));
|
||||
return rv;
|
||||
|
@ -2010,9 +1975,6 @@ nsNSSComponent::Init()
|
|||
|
||||
|
||||
rv = InitializeNSS();
|
||||
#ifdef ANDROID
|
||||
MOZ_RELEASE_ASSERT(NS_SUCCEEDED(rv));
|
||||
#endif
|
||||
if (NS_FAILED(rv)) {
|
||||
MOZ_LOG(gPIPNSSLog, LogLevel::Error,
|
||||
("nsNSSComponent::InitializeNSS() failed\n"));
|
||||
|
@ -2170,9 +2132,6 @@ nsNSSComponent::RegisterObservers()
|
|||
|
||||
nsCOMPtr<nsIObserverService> observerService(
|
||||
do_GetService("@mozilla.org/observer-service;1"));
|
||||
#ifdef ANDROID
|
||||
MOZ_RELEASE_ASSERT(observerService);
|
||||
#endif
|
||||
if (!observerService) {
|
||||
MOZ_LOG(gPIPNSSLog, LogLevel::Debug,
|
||||
("nsNSSComponent: couldn't get observer service\n"));
|
||||
|
@ -2394,9 +2353,6 @@ InitializeCipherSuite()
|
|||
NS_ASSERTION(NS_IsMainThread(), "InitializeCipherSuite() can only be accessed in main thread");
|
||||
|
||||
if (NSS_SetDomesticPolicy() != SECSuccess) {
|
||||
#ifdef ANDROID
|
||||
MOZ_RELEASE_ASSERT(false);
|
||||
#endif
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
5e59e858012d
|
||||
6353ce63e18f
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
FROM ubuntu:16.04
|
||||
MAINTAINER Tim Taubert <ttaubert@mozilla.com>
|
||||
|
||||
RUN useradd -d /home/worker -s /bin/bash -m worker
|
||||
WORKDIR /home/worker
|
||||
|
||||
# Add build and test scripts.
|
||||
ADD bin /home/worker/bin
|
||||
RUN chmod +x /home/worker/bin/*
|
||||
|
||||
# Install dependencies.
|
||||
ADD setup.sh /tmp/setup.sh
|
||||
RUN bash /tmp/setup.sh
|
||||
|
||||
# Env variables.
|
||||
ENV HOME /home/worker
|
||||
ENV SHELL /bin/bash
|
||||
ENV USER worker
|
||||
ENV LOGNAME worker
|
||||
ENV HOSTNAME taskcluster-worker
|
||||
ENV LANG en_US.UTF-8
|
||||
ENV LC_ALL en_US.UTF-8
|
||||
ENV HOST localhost
|
||||
ENV DOMSUF localdomain
|
||||
|
||||
# Set a default command for debugging.
|
||||
CMD ["/bin/bash", "--login"]
|
|
@ -0,0 +1,20 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -v -e -x
|
||||
|
||||
if [ $(id -u) = 0 ]; then
|
||||
# Drop privileges by re-running this script.
|
||||
exec su worker $0
|
||||
fi
|
||||
|
||||
# Default values for testing.
|
||||
REVISION=${NSS_HEAD_REVISION:-default}
|
||||
REPOSITORY=${NSS_HEAD_REPOSITORY:-https://hg.mozilla.org/projects/nss}
|
||||
|
||||
# Clone NSS.
|
||||
for i in 0 2 5; do
|
||||
sleep $i
|
||||
hg clone -r $REVISION $REPOSITORY nss && exit 0
|
||||
rm -rf nss
|
||||
done
|
||||
exit 1
|
|
@ -0,0 +1,54 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -v -e -x
|
||||
|
||||
# Update packages.
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
apt-get -y update && apt-get -y upgrade
|
||||
|
||||
# Need this to add keys for PPAs below.
|
||||
apt-get install -y --no-install-recommends apt-utils
|
||||
|
||||
apt_packages=()
|
||||
apt_packages+=('build-essential')
|
||||
apt_packages+=('ca-certificates')
|
||||
apt_packages+=('curl')
|
||||
apt_packages+=('git')
|
||||
apt_packages+=('gyp')
|
||||
apt_packages+=('ninja-build')
|
||||
apt_packages+=('pkg-config')
|
||||
apt_packages+=('zlib1g-dev')
|
||||
|
||||
# ct-verif and sanitizers
|
||||
apt_packages+=('valgrind')
|
||||
|
||||
# Latest Mercurial.
|
||||
apt_packages+=('mercurial')
|
||||
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 41BD8711B1F0EC2B0D85B91CF59CE3A8323293EE
|
||||
echo "deb http://ppa.launchpad.net/mercurial-ppa/releases/ubuntu xenial main" > /etc/apt/sources.list.d/mercurial.list
|
||||
|
||||
# Install packages.
|
||||
apt-get -y update
|
||||
apt-get install -y --no-install-recommends ${apt_packages[@]}
|
||||
|
||||
# Install LLVM/clang-4.0.
|
||||
mkdir clang-tmp
|
||||
git clone -n --depth 1 https://chromium.googlesource.com/chromium/src/tools/clang clang-tmp/clang
|
||||
git -C clang-tmp/clang checkout HEAD scripts/update.py
|
||||
clang-tmp/clang/scripts/update.py
|
||||
rm -fr clang-tmp
|
||||
|
||||
# Link to LLVM binaries.
|
||||
for b in clang clang++ llvm-symbolizer; do
|
||||
ln -s /home/worker/third_party/llvm-build/Release+Asserts/bin/$b /usr/local/bin/$b
|
||||
done
|
||||
|
||||
locale-gen en_US.UTF-8
|
||||
dpkg-reconfigure locales
|
||||
|
||||
# Cleanup.
|
||||
rm -rf ~/.ccache ~/.cache
|
||||
apt-get autoremove -y
|
||||
apt-get clean
|
||||
apt-get autoclean
|
||||
rm $0
|
|
@ -6,6 +6,7 @@ import merge from "./merge";
|
|||
import * as queue from "./queue";
|
||||
|
||||
const LINUX_IMAGE = {name: "linux", path: "automation/taskcluster/docker"};
|
||||
const FUZZ_IMAGE = {name: "fuzz", path: "automation/taskcluster/docker-fuzz"};
|
||||
|
||||
const WINDOWS_CHECKOUT_CMD =
|
||||
"bash -c \"hg clone -r $NSS_HEAD_REVISION $NSS_HEAD_REPOSITORY nss || " +
|
||||
|
@ -270,7 +271,7 @@ async function scheduleFuzzing() {
|
|||
},
|
||||
platform: "linux64",
|
||||
collection: "fuzz",
|
||||
image: LINUX_IMAGE
|
||||
image: FUZZ_IMAGE
|
||||
};
|
||||
|
||||
// Build base definition.
|
||||
|
@ -279,7 +280,7 @@ async function scheduleFuzzing() {
|
|||
"/bin/bash",
|
||||
"-c",
|
||||
"bin/checkout.sh && " +
|
||||
"nss/automation/taskcluster/scripts/build_gyp.sh -g -v --fuzz --ubsan"
|
||||
"nss/automation/taskcluster/scripts/build_gyp.sh -g -v --fuzz"
|
||||
],
|
||||
artifacts: {
|
||||
public: {
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
[
|
||||
{
|
||||
"version": "Visual Studio 2015 Update 2 / SDK 10.0.10586.0/212",
|
||||
"size": 332442800,
|
||||
"digest": "995394a4a515c7cb0f8595f26f5395361a638870dd0bbfcc22193fe1d98a0c47126057d5999cc494f3f3eac5cb49160e79757c468f83ee5797298e286ef6252c",
|
||||
"version": "Visual Studio 2015 Update 3 14.0.25425.01 / SDK 10.0.14393.0",
|
||||
"size": 326656969,
|
||||
"digest": "babc414ffc0457d27f5a1ed24a8e4873afbe2f1c1a4075469a27c005e1babc3b2a788f643f825efedff95b79686664c67ec4340ed535487168a3482e68559bc7",
|
||||
"algorithm": "sha512",
|
||||
"filename": "vs2015u2.zip",
|
||||
"filename": "vs2015u3.zip",
|
||||
"unpack": true
|
||||
}
|
||||
]
|
||||
|
|
|
@ -18,7 +18,7 @@ hg_clone() {
|
|||
hg_clone https://hg.mozilla.org/build/tools tools default
|
||||
|
||||
tools/scripts/tooltool/tooltool_wrapper.sh $(dirname $0)/releng.manifest https://api.pub.build.mozilla.org/tooltool/ non-existant-file.sh /c/mozilla-build/python/python.exe /c/builds/tooltool.py --authentication-file /c/builds/relengapi.tok -c /c/builds/tooltool_cache
|
||||
VSPATH="$(pwd)/vs2015u2"
|
||||
VSPATH="$(pwd)/vs2015u3"
|
||||
|
||||
export WINDOWSSDKDIR="${VSPATH}/SDK"
|
||||
export WIN32_REDIST_DIR="${VSPATH}/VC/redist/x64/Microsoft.VC140.CRT"
|
||||
|
@ -26,5 +26,5 @@ export WIN_UCRT_REDIST_DIR="${VSPATH}/SDK/Redist/ucrt/DLLs/x64"
|
|||
|
||||
export PATH="${VSPATH}/VC/bin/amd64:${VSPATH}/VC/bin:${VSPATH}/SDK/bin/x64:${VSPATH}/VC/redist/x64/Microsoft.VC140.CRT:${VSPATH}/SDK/Redist/ucrt/DLLs/x64:${PATH}"
|
||||
|
||||
export INCLUDE="${VSPATH}/VC/include:${VSPATH}/SDK/Include/10.0.10586.0/ucrt:${VSPATH}/SDK/Include/10.0.10586.0/shared:${VSPATH}/SDK/Include/10.0.10586.0/um"
|
||||
export LIB="${VSPATH}/VC/lib/amd64:${VSPATH}/SDK/lib/10.0.10586.0/ucrt/x64:${VSPATH}/SDK/lib/10.0.10586.0/um/x64"
|
||||
export INCLUDE="${VSPATH}/VC/include:${VSPATH}/SDK/Include/10.0.14393.0/ucrt:${VSPATH}/SDK/Include/10.0.14393.0/shared:${VSPATH}/SDK/Include/10.0.14393.0/um"
|
||||
export LIB="${VSPATH}/VC/lib/amd64:${VSPATH}/SDK/lib/10.0.14393.0/ucrt/x64:${VSPATH}/SDK/lib/10.0.14393.0/um/x64"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
# This script builds NSS with gyp and ninja.
|
||||
#
|
||||
# This build system is still under development. It does not yet support all
|
||||
|
@ -36,6 +36,7 @@ NSS build tool options:
|
|||
--opt|-o do an opt build
|
||||
--asan do an asan build
|
||||
--ubsan do an ubsan build
|
||||
--ubsan=bool,shift,... sets specific UB sanitizers
|
||||
--msan do an msan build
|
||||
--sancov do sanitize coverage builds
|
||||
--sancov=func sets coverage to function level for example
|
||||
|
@ -54,11 +55,11 @@ rebuild_gyp=0
|
|||
target=Debug
|
||||
verbose=0
|
||||
fuzz=0
|
||||
sancov_default=edge,indirect-calls,8bit-counters
|
||||
ubsan_default=bool,signed-integer-overflow,shift,vptr
|
||||
|
||||
# parse parameters to store in config
|
||||
params=$(echo "$*" | perl -pe 's/-c|-v|-g|-j [0-9]*|-h//g' | perl -pe 's/^\s*(.*?)\s*$/\1/')
|
||||
params=$(echo "$params $CC $CCC" | tr " " "\n" | perl -pe '/^\s*$/d')
|
||||
params=$(echo "$params $CC $CCC" | tr " " "\n" | perl -pe 's/^\s*$//')
|
||||
params=$(echo "${params[*]}" | sort)
|
||||
|
||||
cwd=$(cd $(dirname $0); pwd -P)
|
||||
|
@ -74,13 +75,30 @@ gyp_params=()
|
|||
ninja_params=()
|
||||
scanbuild=()
|
||||
|
||||
sancov_default()
|
||||
{
|
||||
clang_version=$($CC --version | grep -oE 'clang version (3\.9\.|4\.)')
|
||||
if [ -z "$clang_version" ]; then
|
||||
echo "Need at least clang-3.9 (better 4.0) for sancov." 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$clang_version" = "clang version 3.9." ]; then
|
||||
echo edge,indirect-calls,8bit-counters
|
||||
else
|
||||
echo trace-pc-guard
|
||||
fi
|
||||
}
|
||||
|
||||
enable_fuzz()
|
||||
{
|
||||
fuzz=1
|
||||
nspr_sanitizer asan
|
||||
nspr_sanitizer sancov $sancov_default
|
||||
nspr_sanitizer ubsan $ubsan_default
|
||||
nspr_sanitizer sancov $(sancov_default)
|
||||
gyp_params+=(-Duse_asan=1)
|
||||
gyp_params+=(-Duse_sancov=$sancov_default)
|
||||
gyp_params+=(-Duse_ubsan=$ubsan_default)
|
||||
gyp_params+=(-Duse_sancov=$(sancov_default))
|
||||
|
||||
# Adding debug symbols even for opt builds.
|
||||
nspr_opt+=(--enable-debug-symbols)
|
||||
|
@ -100,8 +118,9 @@ while [ $# -gt 0 ]; do
|
|||
--opt|-o) opt_build=1 ;;
|
||||
-m32|--m32) build_64=0 ;;
|
||||
--asan) gyp_params+=(-Duse_asan=1); nspr_sanitizer asan ;;
|
||||
--ubsan) gyp_params+=(-Duse_ubsan=1); nspr_sanitizer ubsan ;;
|
||||
--sancov) gyp_params+=(-Duse_sancov=$sancov_default); nspr_sanitizer sancov $sancov_default ;;
|
||||
--ubsan) gyp_params+=(-Duse_ubsan=$ubsan_default); nspr_sanitizer ubsan $ubsan_default ;;
|
||||
--ubsan=?*) gyp_params+=(-Duse_ubsan="${1#*=}"); nspr_sanitizer ubsan "${1#*=}" ;;
|
||||
--sancov) gyp_params+=(-Duse_sancov=$(sancov_default)); nspr_sanitizer sancov $(sancov_default) ;;
|
||||
--sancov=?*) gyp_params+=(-Duse_sancov="${1#*=}"); nspr_sanitizer sancov "${1#*=}" ;;
|
||||
--pprof) gyp_params+=(-Duse_pprof=1) ;;
|
||||
--msan) gyp_params+=(-Duse_msan=1); nspr_sanitizer msan ;;
|
||||
|
|
|
@ -917,6 +917,7 @@ setupIO(PLArenaPool *arena, bltestIO *input, PRFileDesc *file,
|
|||
SECItem *in;
|
||||
unsigned char *tok;
|
||||
unsigned int i, j;
|
||||
PRBool needToFreeFile = PR_FALSE;
|
||||
|
||||
if (file && (numBytes == 0 || file == PR_STDIN)) {
|
||||
/* grabbing data from a file */
|
||||
|
@ -924,6 +925,7 @@ setupIO(PLArenaPool *arena, bltestIO *input, PRFileDesc *file,
|
|||
if (rv != SECSuccess)
|
||||
return SECFailure;
|
||||
in = &fileData;
|
||||
needToFreeFile = PR_TRUE;
|
||||
} else if (str) {
|
||||
/* grabbing data from command line */
|
||||
fileData.data = (unsigned char *)str;
|
||||
|
@ -957,10 +959,7 @@ setupIO(PLArenaPool *arena, bltestIO *input, PRFileDesc *file,
|
|||
--in->len;
|
||||
if (in->data[in->len - 1] == '\r')
|
||||
--in->len;
|
||||
SECITEM_CopyItem(arena, &input->buf, in);
|
||||
if (rv != SECSuccess) {
|
||||
return SECFailure;
|
||||
}
|
||||
rv = SECITEM_CopyItem(arena, &input->buf, in);
|
||||
break;
|
||||
case bltestHexSpaceDelim:
|
||||
SECITEM_AllocItem(arena, &input->buf, in->len / 5);
|
||||
|
@ -986,7 +985,7 @@ setupIO(PLArenaPool *arena, bltestIO *input, PRFileDesc *file,
|
|||
break;
|
||||
}
|
||||
|
||||
if (file)
|
||||
if (needToFreeFile)
|
||||
SECITEM_FreeItem(&fileData, PR_FALSE);
|
||||
return rv;
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@
|
|||
char *progName;
|
||||
|
||||
static CERTCertificateRequest *
|
||||
GetCertRequest(const SECItem *reqDER)
|
||||
GetCertRequest(const SECItem *reqDER, void *pwarg)
|
||||
{
|
||||
CERTCertificateRequest *certReq = NULL;
|
||||
CERTSignedData signedData;
|
||||
|
@ -83,7 +83,7 @@ GetCertRequest(const SECItem *reqDER)
|
|||
break;
|
||||
}
|
||||
rv = CERT_VerifySignedDataWithPublicKeyInfo(&signedData,
|
||||
&certReq->subjectPublicKeyInfo, NULL /* wincx */);
|
||||
&certReq->subjectPublicKeyInfo, pwarg);
|
||||
} while (0);
|
||||
|
||||
if (rv) {
|
||||
|
@ -2000,7 +2000,7 @@ CreateCert(
|
|||
|
||||
do {
|
||||
/* Create a certrequest object from the input cert request der */
|
||||
certReq = GetCertRequest(certReqDER);
|
||||
certReq = GetCertRequest(certReqDER, pwarg);
|
||||
if (certReq == NULL) {
|
||||
GEN_BREAK(SECFailure)
|
||||
}
|
||||
|
|
|
@ -66,8 +66,11 @@ FindCRL(CERTCertDBHandle *certHandle, char *name, int type)
|
|||
return ((CERTSignedCrl *)NULL);
|
||||
}
|
||||
} else {
|
||||
SECITEM_CopyItem(NULL, &derName, &cert->derSubject);
|
||||
SECStatus rv = SECITEM_CopyItem(NULL, &derName, &cert->derSubject);
|
||||
CERT_DestroyCertificate(cert);
|
||||
if (rv != SECSuccess) {
|
||||
return ((CERTSignedCrl *)NULL);
|
||||
}
|
||||
}
|
||||
|
||||
crl = SEC_FindCrlByName(certHandle, &derName, type);
|
||||
|
@ -373,7 +376,7 @@ static CERTSignedCrl *
|
|||
CreateModifiedCRLCopy(PLArenaPool *arena, CERTCertDBHandle *certHandle,
|
||||
CERTCertificate **cert, char *certNickName,
|
||||
PRFileDesc *inFile, PRInt32 decodeOptions,
|
||||
PRInt32 importOptions)
|
||||
PRInt32 importOptions, secuPWData *pwdata)
|
||||
{
|
||||
SECItem crlDER = { 0, NULL, 0 };
|
||||
CERTSignedCrl *signCrl = NULL;
|
||||
|
@ -419,7 +422,7 @@ CreateModifiedCRLCopy(PLArenaPool *arena, CERTCertDBHandle *certHandle,
|
|||
}
|
||||
|
||||
rv = CERT_VerifySignedData(&modCrl->signatureWrap, *cert,
|
||||
PR_Now(), NULL);
|
||||
PR_Now(), pwdata);
|
||||
if (rv != SECSuccess) {
|
||||
SECU_PrintError(progName, "fail to verify signed data\n");
|
||||
goto loser;
|
||||
|
@ -707,7 +710,8 @@ GenerateCRL(CERTCertDBHandle *certHandle, char *certNickName,
|
|||
|
||||
if (modifyFlag == PR_TRUE) {
|
||||
signCrl = CreateModifiedCRLCopy(arena, certHandle, &cert, certNickName,
|
||||
inFile, decodeOptions, importOptions);
|
||||
inFile, decodeOptions, importOptions,
|
||||
pwdata);
|
||||
if (signCrl == NULL) {
|
||||
rv = SECFailure;
|
||||
goto loser;
|
||||
|
|
|
@ -473,6 +473,7 @@ signed_data(struct signOptionsStr *signOptions)
|
|||
fprintf(stderr,
|
||||
"Created CMS message, added signed data w/ signerinfo\n");
|
||||
}
|
||||
signerinfo->cmsg->pwfn_arg = pwcb_arg;
|
||||
/* we want the cert chain included for this one */
|
||||
if (NSS_CMSSignerInfo_IncludeCerts(signerinfo, NSSCMSCM_CertChain,
|
||||
signOptions->options->certUsage) !=
|
||||
|
|
|
@ -106,16 +106,6 @@ ifneq ($(OS_TARGET),Android)
|
|||
LIBC_TAG = _glibc
|
||||
endif
|
||||
|
||||
ifeq ($(OS_RELEASE),2.0)
|
||||
OS_REL_CFLAGS += -DLINUX2_0
|
||||
MKSHLIB = $(CC) -shared -Wl,-soname -Wl,$(@:$(OBJDIR)/%.so=%.so) $(RPATH)
|
||||
ifdef MAPFILE
|
||||
MKSHLIB += -Wl,--version-script,$(MAPFILE)
|
||||
endif
|
||||
PROCESS_MAP_FILE = grep -v ';-' $< | \
|
||||
sed -e 's,;+,,' -e 's; DATA ;;' -e 's,;;,,' -e 's,;.*,;,' > $@
|
||||
endif
|
||||
|
||||
ifdef BUILD_OPT
|
||||
ifeq (11,$(ALLOW_OPT_CODE_SIZE)$(OPT_CODE_SIZE))
|
||||
OPTIMIZER = -Os
|
||||
|
@ -139,15 +129,16 @@ ifeq ($(USE_PTHREADS),1)
|
|||
OS_PTHREAD = -lpthread
|
||||
endif
|
||||
|
||||
OS_CFLAGS = $(DSO_CFLAGS) $(OS_REL_CFLAGS) $(ARCHFLAG) -pipe -ffunction-sections -fdata-sections -DLINUX -Dlinux -DHAVE_STRERROR
|
||||
OS_CFLAGS = $(DSO_CFLAGS) $(OS_REL_CFLAGS) $(ARCHFLAG) -pipe -ffunction-sections -fdata-sections -DHAVE_STRERROR
|
||||
ifeq ($(KERNEL),Linux)
|
||||
OS_CFLAGS += -DLINUX -Dlinux
|
||||
endif
|
||||
OS_LIBS = $(OS_PTHREAD) -ldl -lc
|
||||
|
||||
ifdef USE_PTHREADS
|
||||
DEFINES += -D_REENTRANT
|
||||
endif
|
||||
|
||||
ARCH = linux
|
||||
|
||||
DSO_CFLAGS = -fPIC
|
||||
DSO_LDOPTS = -shared $(ARCHFLAG) -Wl,--gc-sections
|
||||
# The linker on Red Hat Linux 7.2 and RHEL 2.1 (GNU ld version 2.11.90.0.8)
|
||||
|
@ -167,7 +158,6 @@ ifdef _SBOX_DIR
|
|||
LDFLAGS += -Wl,-rpath-link,/usr/lib:/lib
|
||||
endif
|
||||
|
||||
# INCLUDES += -I/usr/include -Y/usr/include/linux
|
||||
G++INCLUDES = -I/usr/include/g++
|
||||
|
||||
#
|
||||
|
@ -202,7 +192,6 @@ RPATH = -Wl,-rpath,'$$ORIGIN:/opt/sun/private/lib'
|
|||
endif
|
||||
endif
|
||||
|
||||
OS_REL_CFLAGS += -DLINUX2_1
|
||||
MKSHLIB = $(CC) $(DSO_LDOPTS) -Wl,-soname -Wl,$(@:$(OBJDIR)/%.so=%.so) $(RPATH)
|
||||
|
||||
ifdef MAPFILE
|
||||
|
|
|
@ -115,6 +115,20 @@ ifeq ($(OS_ARCH),Linux)
|
|||
ifneq ($(words $(OS_RELEASE)),1)
|
||||
OS_RELEASE := $(word 1,$(OS_RELEASE)).$(word 2,$(OS_RELEASE))
|
||||
endif
|
||||
KERNEL = Linux
|
||||
endif
|
||||
|
||||
# Since all uses of OS_ARCH that follow affect only userland, we can
|
||||
# merge other Glibc systems with Linux here.
|
||||
ifeq ($(OS_ARCH),GNU)
|
||||
OS_ARCH = Linux
|
||||
OS_RELEASE = 2.6
|
||||
KERNEL = GNU
|
||||
endif
|
||||
ifeq ($(OS_ARCH),GNU_kFreeBSD)
|
||||
OS_ARCH = Linux
|
||||
OS_RELEASE = 2.6
|
||||
KERNEL = FreeBSD
|
||||
endif
|
||||
|
||||
#
|
||||
|
|
|
@ -6,15 +6,16 @@ import sys
|
|||
|
||||
def main():
|
||||
if sys.platform == 'win32':
|
||||
print 0
|
||||
print(0)
|
||||
else:
|
||||
cc = os.environ.get('CC', 'cc')
|
||||
try:
|
||||
cc_is_clang = 'clang' in subprocess.check_output([cc, '--version'])
|
||||
cc_is_clang = 'clang' in subprocess.check_output(
|
||||
[cc, '--version'], universal_newlines=True)
|
||||
except OSError:
|
||||
# We probably just don't have CC/cc.
|
||||
cc_is_clang = False
|
||||
print int(cc_is_clang)
|
||||
print(int(cc_is_clang))
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
|
@ -24,39 +24,45 @@
|
|||
# building on.
|
||||
'target_arch%': '<(host_arch)',
|
||||
}],
|
||||
['OS=="linux"', {
|
||||
# FIPS-140 LOWHASH
|
||||
'freebl_name': 'freeblpriv3',
|
||||
}, {
|
||||
'freebl_name': 'freebl3',
|
||||
}],
|
||||
['OS=="mac"', {
|
||||
'use_system_sqlite%': 1,
|
||||
},{
|
||||
'use_system_sqlite%': 0,
|
||||
}],
|
||||
['OS=="mac" or OS=="win"', {
|
||||
'cc_use_gnu_ld%': 0,
|
||||
}, {
|
||||
'cc_use_gnu_ld%': 1,
|
||||
}],
|
||||
['OS=="win"', {
|
||||
'use_system_zlib%': 0,
|
||||
'nspr_libs%': ['nspr4.lib', 'plc4.lib', 'plds4.lib'],
|
||||
'nspr_libs%': ['libnspr4.lib', 'libplc4.lib', 'libplds4.lib'],
|
||||
'zlib_libs%': [],
|
||||
#TODO
|
||||
'moz_debug_flags%': '',
|
||||
'dll_prefix': '',
|
||||
'dll_suffix': 'dll',
|
||||
}, {
|
||||
'nspr_libs%': ['-lplds4', '-lplc4', '-lnspr4'],
|
||||
'use_system_zlib%': 1,
|
||||
}],
|
||||
['OS=="linux" or OS=="android"', {
|
||||
'nspr_libs%': ['-lplds4', '-lplc4', '-lnspr4'],
|
||||
'zlib_libs%': ['-lz'],
|
||||
'moz_debug_flags%': '-gdwarf-2',
|
||||
'optimize_flags%': '-O2',
|
||||
'dll_prefix': 'lib',
|
||||
'dll_suffix': 'so',
|
||||
}],
|
||||
['OS=="linux"', {
|
||||
'freebl_name': 'freeblpriv3',
|
||||
}, {
|
||||
'freebl_name': 'freebl3',
|
||||
}],
|
||||
'conditions': [
|
||||
['OS=="mac"', {
|
||||
'zlib_libs%': ['-lz'],
|
||||
'use_system_sqlite%': 1,
|
||||
'moz_debug_flags%': '-gdwarf-2 -gfull',
|
||||
'optimize_flags%': '-O2',
|
||||
'dll_prefix': 'lib',
|
||||
'dll_suffix': 'dylib',
|
||||
}, {
|
||||
'use_system_sqlite%': 0,
|
||||
'moz_debug_flags%': '-gdwarf-2',
|
||||
'dll_suffix': 'so',
|
||||
}],
|
||||
],
|
||||
}],
|
||||
['"<(GENERATOR)"=="ninja"', {
|
||||
'cc_is_clang%': '<!(<(python) <(DEPTH)/coreconf/check_cc_clang.py)',
|
||||
|
@ -81,6 +87,7 @@
|
|||
'dll_suffix': '<(dll_suffix)',
|
||||
'freebl_name': '<(freebl_name)',
|
||||
'cc_is_clang%': '<(cc_is_clang)',
|
||||
'cc_use_gnu_ld%': '<(cc_use_gnu_ld)',
|
||||
# Some defaults
|
||||
'disable_tests%': 0,
|
||||
'disable_chachapoly%': 0,
|
||||
|
@ -115,9 +122,13 @@
|
|||
'<(nss_dist_dir)/private/<(module)',
|
||||
],
|
||||
'conditions': [
|
||||
[ 'OS=="linux"', {
|
||||
[ 'OS!="android" and OS!="mac" and OS!="win"', {
|
||||
'libraries': [
|
||||
'-lpthread',
|
||||
],
|
||||
}],
|
||||
[ 'OS=="linux"', {
|
||||
'libraries': [
|
||||
'-ldl',
|
||||
'-lc',
|
||||
],
|
||||
|
@ -148,7 +159,7 @@
|
|||
],
|
||||
},
|
||||
'conditions': [
|
||||
[ 'OS=="linux" or OS=="android"', {
|
||||
[ 'cc_use_gnu_ld==1', {
|
||||
'ldflags': [
|
||||
'-Wl,--version-script,<(INTERMEDIATE_DIR)/out.>(mapfile)',
|
||||
],
|
||||
|
@ -195,11 +206,19 @@
|
|||
# Shared library specific settings.
|
||||
[ '_type=="shared_library"', {
|
||||
'conditions': [
|
||||
[ 'OS=="linux" or OS=="android"', {
|
||||
[ 'cc_use_gnu_ld==1', {
|
||||
'ldflags': [
|
||||
'-Wl,--gc-sections',
|
||||
'-Wl,-z,defs',
|
||||
],
|
||||
'conditions': [
|
||||
['OS=="dragonfly" or OS=="freebsd" or OS=="netbsd" or OS=="openbsd"', {
|
||||
# Bug 1321317 - unix_rand.c:880: undefined reference to `environ'
|
||||
'ldflags': [
|
||||
'-Wl,--warn-unresolved-symbols',
|
||||
],
|
||||
}],
|
||||
],
|
||||
}],
|
||||
],
|
||||
'xcode_settings': {
|
||||
|
@ -251,10 +270,36 @@
|
|||
'LINUX2_1',
|
||||
'LINUX',
|
||||
'linux',
|
||||
],
|
||||
}],
|
||||
[ 'OS=="dragonfly" or OS=="freebsd"', {
|
||||
'defines': [
|
||||
'FREEBSD',
|
||||
],
|
||||
}],
|
||||
[ 'OS=="netbsd"', {
|
||||
'defines': [
|
||||
'NETBSD',
|
||||
],
|
||||
}],
|
||||
[ 'OS=="openbsd"', {
|
||||
'defines': [
|
||||
'OPENBSD',
|
||||
],
|
||||
}],
|
||||
['OS=="mac" or OS=="dragonfly" or OS=="freebsd" or OS=="netbsd" or OS=="openbsd"', {
|
||||
'defines': [
|
||||
'HAVE_BSD_FLOCK',
|
||||
],
|
||||
}],
|
||||
[ 'OS!="win"', {
|
||||
'defines': [
|
||||
'HAVE_STRERROR',
|
||||
'XP_UNIX',
|
||||
'_REENTRANT',
|
||||
],
|
||||
}],
|
||||
[ 'OS!="mac" and OS!="win"', {
|
||||
'cflags': [
|
||||
'-fPIC',
|
||||
'-pipe',
|
||||
|
@ -275,18 +320,23 @@
|
|||
}],
|
||||
],
|
||||
}],
|
||||
[ 'use_pprof==1 and OS=="linux"', {
|
||||
'ldflags': [ '-lprofiler' ],
|
||||
}],
|
||||
[ 'use_pprof==1 and OS=="mac"', {
|
||||
[ 'use_pprof==1 and OS!="android" and OS!="win"', {
|
||||
'conditions': [
|
||||
[ 'OS=="mac"', {
|
||||
'xcode_settings': {
|
||||
'OTHER_LDFLAGS': [ '-lprofiler' ],
|
||||
},
|
||||
}, {
|
||||
'ldflags': [ '-lprofiler' ],
|
||||
}],
|
||||
[ 'OS!="linux"', {
|
||||
'library_dirs': [
|
||||
'/usr/local/lib/',
|
||||
],
|
||||
}],
|
||||
[ 'disable_werror==0 and (OS=="linux" or OS=="mac")', {
|
||||
],
|
||||
}],
|
||||
[ 'disable_werror==0 and OS!="android" and OS!="win"', {
|
||||
'cflags': [
|
||||
'<!@(<(python) <(DEPTH)/coreconf/werror.py)',
|
||||
],
|
||||
|
@ -296,7 +346,7 @@
|
|||
'-Wno-unused-function',
|
||||
]
|
||||
}],
|
||||
[ 'fuzz==1 or use_asan==1 or use_ubsan==1', {
|
||||
[ 'fuzz==1 or use_asan==1 or use_ubsan!=0', {
|
||||
'cflags': ['-O1'],
|
||||
'xcode_settings': {
|
||||
'GCC_OPTIMIZATION_LEVEL': '1', # -O1
|
||||
|
@ -321,9 +371,9 @@
|
|||
'LIBRARY_SEARCH_PATHS': ['/usr/lib <(asan_flags)'],
|
||||
},
|
||||
}],
|
||||
[ 'use_ubsan==1', {
|
||||
[ 'use_ubsan!=0', {
|
||||
'variables': {
|
||||
'ubsan_flags': '<!(<(python) <(DEPTH)/coreconf/sanitizers.py ubsan)',
|
||||
'ubsan_flags': '<!(<(python) <(DEPTH)/coreconf/sanitizers.py ubsan <(use_ubsan))',
|
||||
'no_ldflags': '<!(<(python) <(DEPTH)/coreconf/sanitizers.py ld)',
|
||||
},
|
||||
'cflags': ['<@(ubsan_flags)'],
|
||||
|
@ -376,9 +426,6 @@
|
|||
[ 'OS=="mac"', {
|
||||
'defines': [
|
||||
'DARWIN',
|
||||
'HAVE_STRERROR',
|
||||
'HAVE_BSD_FLOCK',
|
||||
'XP_UNIX',
|
||||
],
|
||||
'conditions': [
|
||||
[ 'target_arch=="ia32"', {
|
||||
|
@ -459,7 +506,7 @@
|
|||
'Debug': {
|
||||
'inherit_from': ['Common'],
|
||||
'conditions': [
|
||||
[ 'OS=="linux" or OS=="android"', {
|
||||
[ 'OS!="mac" and OS!="win"', {
|
||||
'cflags': [
|
||||
'-g',
|
||||
'<(moz_debug_flags)',
|
||||
|
@ -524,9 +571,9 @@
|
|||
},
|
||||
},
|
||||
'conditions': [
|
||||
[ 'OS=="linux" or OS=="android"', {
|
||||
[ 'cc_use_gnu_ld==1', {
|
||||
'variables': {
|
||||
'process_map_file': ['/bin/sh', '-c', '/bin/grep -v ";-" >(mapfile) | sed -e "s,;+,," -e "s; DATA ;;" -e "s,;;,," -e "s,;.*,;," > >@(_outputs)'],
|
||||
'process_map_file': ['/bin/sh', '-c', '/usr/bin/env grep -v ";-" >(mapfile) | sed -e "s,;+,," -e "s; DATA ;;" -e "s,;;,," -e "s,;.*,;," > >@(_outputs)'],
|
||||
},
|
||||
}],
|
||||
[ 'OS=="mac"', {
|
||||
|
|
|
@ -10,4 +10,3 @@
|
|||
*/
|
||||
|
||||
#error "Do not include this header file."
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
# This script builds NSPR for NSS.
|
||||
#
|
||||
# This build system is still under development. It does not yet support all
|
||||
|
@ -10,6 +10,11 @@ nspr_cflags=
|
|||
nspr_cxxflags=
|
||||
nspr_ldflags=
|
||||
|
||||
# Try to avoid bmake on OS X and BSD systems
|
||||
if hash gmake 2>/dev/null; then
|
||||
make() { command gmake "$@"; }
|
||||
fi
|
||||
|
||||
nspr_sanitizer()
|
||||
{
|
||||
nspr_cflags="$nspr_cflags $(python $cwd/coreconf/sanitizers.py $1 $2)"
|
||||
|
|
|
@ -9,7 +9,9 @@ def main():
|
|||
|
||||
sanitizer = sys.argv[1]
|
||||
if sanitizer == "ubsan":
|
||||
print('-fsanitize=undefined -fno-sanitize-recover=undefined ', end='')
|
||||
if len(sys.argv) < 3:
|
||||
raise Exception('ubsan requires another argument.')
|
||||
print('-fsanitize='+sys.argv[2]+' -fno-sanitize-recover=undefined ', end='')
|
||||
return
|
||||
if sanitizer == "asan":
|
||||
print('-fsanitize=address ', end='')
|
||||
|
|
|
@ -7,7 +7,8 @@ def main():
|
|||
cc = os.environ.get('CC', 'cc')
|
||||
sink = open(os.devnull, 'wb')
|
||||
try:
|
||||
cc_is_clang = 'clang' in subprocess.check_output([cc, '--version'], stderr=sink)
|
||||
cc_is_clang = 'clang' in subprocess.check_output(
|
||||
[cc, '--version'], universal_newlines=True, stderr=sink)
|
||||
except OSError:
|
||||
# We probably just don't have CC/cc.
|
||||
return
|
||||
|
|
|
@ -345,3 +345,28 @@ SSLCipherAlgorithm SSLInt_CipherSpecToAlgorithm(PRBool isServer,
|
|||
unsigned char *SSLInt_CipherSpecToIv(PRBool isServer, ssl3CipherSpec *spec) {
|
||||
return GetKeyingMaterial(isServer, spec)->write_iv;
|
||||
}
|
||||
|
||||
SECStatus SSLInt_EnableShortHeaders(PRFileDesc *fd) {
|
||||
sslSocket *ss;
|
||||
|
||||
ss = ssl_FindSocket(fd);
|
||||
if (!ss) {
|
||||
return SECFailure;
|
||||
}
|
||||
|
||||
ss->opt.enableShortHeaders = PR_TRUE;
|
||||
return SECSuccess;
|
||||
}
|
||||
|
||||
SECStatus SSLInt_UsingShortHeaders(PRFileDesc *fd, PRBool *result) {
|
||||
sslSocket *ss;
|
||||
|
||||
ss = ssl_FindSocket(fd);
|
||||
if (!ss) {
|
||||
return SECFailure;
|
||||
}
|
||||
|
||||
*result = ss->ssl3.hs.shortHeaders;
|
||||
|
||||
return SECSuccess;
|
||||
}
|
||||
|
|
|
@ -47,5 +47,7 @@ PK11SymKey *SSLInt_CipherSpecToKey(PRBool isServer, ssl3CipherSpec *spec);
|
|||
SSLCipherAlgorithm SSLInt_CipherSpecToAlgorithm(PRBool isServer,
|
||||
ssl3CipherSpec *spec);
|
||||
unsigned char *SSLInt_CipherSpecToIv(PRBool isServer, ssl3CipherSpec *spec);
|
||||
SECStatus SSLInt_EnableShortHeaders(PRFileDesc *fd);
|
||||
SECStatus SSLInt_UsingShortHeaders(PRFileDesc *fd, PRBool *result);
|
||||
|
||||
#endif // ndef libssl_internals_h_
|
||||
|
|
|
@ -96,8 +96,12 @@
|
|||
'../../gtests/common',
|
||||
'../../lib/ssl'
|
||||
],
|
||||
'defines': [
|
||||
'NSS_USE_STATIC_LIBS'
|
||||
],
|
||||
},
|
||||
'variables': {
|
||||
'module': 'nss',
|
||||
'use_static_libs': 1,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -220,6 +220,14 @@ TEST_F(TlsConnectStreamTls13, Tls13FailedWriteSecondFlight) {
|
|||
client_->CheckErrorCode(SSL_ERROR_SOCKET_WRITE_FAILURE);
|
||||
}
|
||||
|
||||
TEST_F(TlsConnectStreamTls13, NegotiateShortHeaders) {
|
||||
client_->SetShortHeadersEnabled();
|
||||
server_->SetShortHeadersEnabled();
|
||||
client_->ExpectShortHeaders();
|
||||
server_->ExpectShortHeaders();
|
||||
Connect();
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(GenericStream, TlsConnectGeneric,
|
||||
::testing::Combine(TlsConnectTestBase::kTlsModesStream,
|
||||
TlsConnectTestBase::kTlsVAll));
|
||||
|
|
|
@ -68,7 +68,8 @@ TlsAgent::TlsAgent(const std::string& name, Role role, Mode mode)
|
|||
expect_readwrite_error_(false),
|
||||
handshake_callback_(),
|
||||
auth_certificate_callback_(),
|
||||
sni_callback_() {
|
||||
sni_callback_(),
|
||||
expect_short_headers_(false) {
|
||||
memset(&info_, 0, sizeof(info_));
|
||||
memset(&csinfo_, 0, sizeof(csinfo_));
|
||||
SECStatus rv = SSL_VersionRangeGetDefault(
|
||||
|
@ -365,6 +366,13 @@ void TlsAgent::Set0RttEnabled(bool en) {
|
|||
EXPECT_EQ(SECSuccess, rv);
|
||||
}
|
||||
|
||||
void TlsAgent::SetShortHeadersEnabled() {
|
||||
EXPECT_TRUE(EnsureTlsSetup());
|
||||
|
||||
SECStatus rv = SSLInt_EnableShortHeaders(ssl_fd_);
|
||||
EXPECT_EQ(SECSuccess, rv);
|
||||
}
|
||||
|
||||
void TlsAgent::SetVersionRange(uint16_t minver, uint16_t maxver) {
|
||||
vrange_.min = minver;
|
||||
vrange_.max = maxver;
|
||||
|
@ -388,6 +396,8 @@ void TlsAgent::SetServerKeyBits(uint16_t bits) { server_key_bits_ = bits; }
|
|||
|
||||
void TlsAgent::ExpectReadWriteError() { expect_readwrite_error_ = true; }
|
||||
|
||||
void TlsAgent::ExpectShortHeaders() { expect_short_headers_ = true; }
|
||||
|
||||
void TlsAgent::SetSignatureSchemes(const SSLSignatureScheme* schemes,
|
||||
size_t count) {
|
||||
EXPECT_TRUE(EnsureTlsSetup());
|
||||
|
@ -658,6 +668,10 @@ void TlsAgent::Connected() {
|
|||
}
|
||||
}
|
||||
|
||||
PRBool short_headers;
|
||||
rv = SSLInt_UsingShortHeaders(ssl_fd_, &short_headers);
|
||||
EXPECT_EQ(SECSuccess, rv);
|
||||
EXPECT_EQ((PRBool)expect_short_headers_, short_headers);
|
||||
SetState(STATE_CONNECTED);
|
||||
}
|
||||
|
||||
|
|
|
@ -129,6 +129,7 @@ class TlsAgent : public PollTarget {
|
|||
void SetSessionTicketsEnabled(bool en);
|
||||
void SetSessionCacheEnabled(bool en);
|
||||
void Set0RttEnabled(bool en);
|
||||
void SetShortHeadersEnabled();
|
||||
void SetVersionRange(uint16_t minver, uint16_t maxver);
|
||||
void GetVersionRange(uint16_t* minver, uint16_t* maxver);
|
||||
void CheckPreliminaryInfo();
|
||||
|
@ -138,6 +139,7 @@ class TlsAgent : public PollTarget {
|
|||
void ExpectReadWriteError();
|
||||
void EnableFalseStart();
|
||||
void ExpectResumption();
|
||||
void ExpectShortHeaders();
|
||||
void SetSignatureSchemes(const SSLSignatureScheme* schemes, size_t count);
|
||||
void EnableAlpn(const uint8_t* val, size_t len);
|
||||
void CheckAlpn(SSLNextProtoState expected_state,
|
||||
|
@ -369,6 +371,7 @@ class TlsAgent : public PollTarget {
|
|||
HandshakeCallbackFunction handshake_callback_;
|
||||
AuthCertificateCallbackFunction auth_certificate_callback_;
|
||||
SniCallbackFunction sni_callback_;
|
||||
bool expect_short_headers_;
|
||||
};
|
||||
|
||||
inline std::ostream& operator<<(std::ostream& stream,
|
||||
|
|
|
@ -1080,7 +1080,10 @@ CERT_CertChainFromCert(CERTCertificate *cert, SECCertUsage usage,
|
|||
derCert.len = (unsigned int)stanCert->encoding.size;
|
||||
derCert.data = (unsigned char *)stanCert->encoding.data;
|
||||
derCert.type = siBuffer;
|
||||
SECITEM_CopyItem(arena, &chain->certs[i], &derCert);
|
||||
if (SECITEM_CopyItem(arena, &chain->certs[i], &derCert) != SECSuccess) {
|
||||
CERT_DestroyCertificate(cCert);
|
||||
goto loser;
|
||||
}
|
||||
stanCert = stanChain[++i];
|
||||
if (!stanCert && !cCert->isRoot) {
|
||||
/* reached the end of the chain, but the final cert is
|
||||
|
|
|
@ -398,6 +398,142 @@ cert_AddToVerifyLog(CERTVerifyLog *log, CERTCertificate *cert, long error,
|
|||
(void *)(PRWord)arg); \
|
||||
}
|
||||
|
||||
/* /C=CN/O=WoSign CA Limited/CN=CA \xE6\xB2\x83\xE9\x80\x9A\xE6\xA0\xB9\xE8\xAF\x81\xE4\xB9\xA6
|
||||
* Using a consistent naming convention, this would actually be called
|
||||
* 'CA沃通根证书DN', but since GCC 6.2.1 apparently can't handle UTF-8
|
||||
* identifiers, this will have to do.
|
||||
*/
|
||||
static const unsigned char CAWoSignRootDN[72] = {
|
||||
0x30, 0x46, 0x31, 0x0B, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02,
|
||||
0x43, 0x4E, 0x31, 0x1A, 0x30, 0x18, 0x06, 0x03, 0x55, 0x04, 0x0A, 0x13, 0x11,
|
||||
0x57, 0x6F, 0x53, 0x69, 0x67, 0x6E, 0x20, 0x43, 0x41, 0x20, 0x4C, 0x69, 0x6D,
|
||||
0x69, 0x74, 0x65, 0x64, 0x31, 0x1B, 0x30, 0x19, 0x06, 0x03, 0x55, 0x04, 0x03,
|
||||
0x0C, 0x12, 0x43, 0x41, 0x20, 0xE6, 0xB2, 0x83, 0xE9, 0x80, 0x9A, 0xE6, 0xA0,
|
||||
0xB9, 0xE8, 0xAF, 0x81, 0xE4, 0xB9, 0xA6,
|
||||
};
|
||||
|
||||
/* /C=CN/O=WoSign CA Limited/CN=CA WoSign ECC Root */
|
||||
static const unsigned char CAWoSignECCRootDN[72] = {
|
||||
0x30, 0x46, 0x31, 0x0B, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02,
|
||||
0x43, 0x4E, 0x31, 0x1A, 0x30, 0x18, 0x06, 0x03, 0x55, 0x04, 0x0A, 0x13, 0x11,
|
||||
0x57, 0x6F, 0x53, 0x69, 0x67, 0x6E, 0x20, 0x43, 0x41, 0x20, 0x4C, 0x69, 0x6D,
|
||||
0x69, 0x74, 0x65, 0x64, 0x31, 0x1B, 0x30, 0x19, 0x06, 0x03, 0x55, 0x04, 0x03,
|
||||
0x13, 0x12, 0x43, 0x41, 0x20, 0x57, 0x6F, 0x53, 0x69, 0x67, 0x6E, 0x20, 0x45,
|
||||
0x43, 0x43, 0x20, 0x52, 0x6F, 0x6F, 0x74,
|
||||
};
|
||||
|
||||
/* /C=CN/O=WoSign CA Limited/CN=Certification Authority of WoSign */
|
||||
static const unsigned char CertificationAuthorityofWoSignDN[87] = {
|
||||
0x30, 0x55, 0x31, 0x0B, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02,
|
||||
0x43, 0x4E, 0x31, 0x1A, 0x30, 0x18, 0x06, 0x03, 0x55, 0x04, 0x0A, 0x13, 0x11,
|
||||
0x57, 0x6F, 0x53, 0x69, 0x67, 0x6E, 0x20, 0x43, 0x41, 0x20, 0x4C, 0x69, 0x6D,
|
||||
0x69, 0x74, 0x65, 0x64, 0x31, 0x2A, 0x30, 0x28, 0x06, 0x03, 0x55, 0x04, 0x03,
|
||||
0x13, 0x21, 0x43, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69,
|
||||
0x6F, 0x6E, 0x20, 0x41, 0x75, 0x74, 0x68, 0x6F, 0x72, 0x69, 0x74, 0x79, 0x20,
|
||||
0x6F, 0x66, 0x20, 0x57, 0x6F, 0x53, 0x69, 0x67, 0x6E,
|
||||
};
|
||||
|
||||
/* /C=CN/O=WoSign CA Limited/CN=Certification Authority of WoSign G2 */
|
||||
static const unsigned char CertificationAuthorityofWoSignG2DN[90] = {
|
||||
0x30, 0x58, 0x31, 0x0B, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02,
|
||||
0x43, 0x4E, 0x31, 0x1A, 0x30, 0x18, 0x06, 0x03, 0x55, 0x04, 0x0A, 0x13, 0x11,
|
||||
0x57, 0x6F, 0x53, 0x69, 0x67, 0x6E, 0x20, 0x43, 0x41, 0x20, 0x4C, 0x69, 0x6D,
|
||||
0x69, 0x74, 0x65, 0x64, 0x31, 0x2D, 0x30, 0x2B, 0x06, 0x03, 0x55, 0x04, 0x03,
|
||||
0x13, 0x24, 0x43, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69,
|
||||
0x6F, 0x6E, 0x20, 0x41, 0x75, 0x74, 0x68, 0x6F, 0x72, 0x69, 0x74, 0x79, 0x20,
|
||||
0x6F, 0x66, 0x20, 0x57, 0x6F, 0x53, 0x69, 0x67, 0x6E, 0x20, 0x47, 0x32,
|
||||
};
|
||||
|
||||
/* /C=IL/O=StartCom Ltd./OU=Secure Digital Certificate Signing/CN=StartCom Certification Authority */
|
||||
static const unsigned char StartComCertificationAuthorityDN[127] = {
|
||||
0x30, 0x7D, 0x31, 0x0B, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02,
|
||||
0x49, 0x4C, 0x31, 0x16, 0x30, 0x14, 0x06, 0x03, 0x55, 0x04, 0x0A, 0x13, 0x0D,
|
||||
0x53, 0x74, 0x61, 0x72, 0x74, 0x43, 0x6F, 0x6D, 0x20, 0x4C, 0x74, 0x64, 0x2E,
|
||||
0x31, 0x2B, 0x30, 0x29, 0x06, 0x03, 0x55, 0x04, 0x0B, 0x13, 0x22, 0x53, 0x65,
|
||||
0x63, 0x75, 0x72, 0x65, 0x20, 0x44, 0x69, 0x67, 0x69, 0x74, 0x61, 0x6C, 0x20,
|
||||
0x43, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x20, 0x53,
|
||||
0x69, 0x67, 0x6E, 0x69, 0x6E, 0x67, 0x31, 0x29, 0x30, 0x27, 0x06, 0x03, 0x55,
|
||||
0x04, 0x03, 0x13, 0x20, 0x53, 0x74, 0x61, 0x72, 0x74, 0x43, 0x6F, 0x6D, 0x20,
|
||||
0x43, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6F, 0x6E,
|
||||
0x20, 0x41, 0x75, 0x74, 0x68, 0x6F, 0x72, 0x69, 0x74, 0x79,
|
||||
};
|
||||
|
||||
/* /C=IL/O=StartCom Ltd./CN=StartCom Certification Authority G2 */
|
||||
static const unsigned char StartComCertificationAuthorityG2DN[85] = {
|
||||
0x30, 0x53, 0x31, 0x0B, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02,
|
||||
0x49, 0x4C, 0x31, 0x16, 0x30, 0x14, 0x06, 0x03, 0x55, 0x04, 0x0A, 0x13, 0x0D,
|
||||
0x53, 0x74, 0x61, 0x72, 0x74, 0x43, 0x6F, 0x6D, 0x20, 0x4C, 0x74, 0x64, 0x2E,
|
||||
0x31, 0x2C, 0x30, 0x2A, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x23, 0x53, 0x74,
|
||||
0x61, 0x72, 0x74, 0x43, 0x6F, 0x6D, 0x20, 0x43, 0x65, 0x72, 0x74, 0x69, 0x66,
|
||||
0x69, 0x63, 0x61, 0x74, 0x69, 0x6F, 0x6E, 0x20, 0x41, 0x75, 0x74, 0x68, 0x6F,
|
||||
0x72, 0x69, 0x74, 0x79, 0x20, 0x47, 0x32,
|
||||
};
|
||||
|
||||
struct DataAndLength {
|
||||
const unsigned char *data;
|
||||
PRUint32 len;
|
||||
};
|
||||
|
||||
static const struct DataAndLength StartComAndWoSignDNs[] = {
|
||||
{ CAWoSignRootDN,
|
||||
sizeof(CAWoSignRootDN) },
|
||||
{ CAWoSignECCRootDN,
|
||||
sizeof(CAWoSignECCRootDN) },
|
||||
{ CertificationAuthorityofWoSignDN,
|
||||
sizeof(CertificationAuthorityofWoSignDN) },
|
||||
{ CertificationAuthorityofWoSignG2DN,
|
||||
sizeof(CertificationAuthorityofWoSignG2DN) },
|
||||
{ StartComCertificationAuthorityDN,
|
||||
sizeof(StartComCertificationAuthorityDN) },
|
||||
{ StartComCertificationAuthorityG2DN,
|
||||
sizeof(StartComCertificationAuthorityG2DN) },
|
||||
};
|
||||
|
||||
static PRBool
|
||||
CertIsStartComOrWoSign(const CERTCertificate *cert)
|
||||
{
|
||||
int i;
|
||||
const struct DataAndLength *dn = StartComAndWoSignDNs;
|
||||
|
||||
for (i = 0; i < sizeof(StartComAndWoSignDNs) / sizeof(struct DataAndLength); ++i, dn++) {
|
||||
if (cert->derSubject.len == dn->len &&
|
||||
memcmp(cert->derSubject.data, dn->data, dn->len) == 0) {
|
||||
return PR_TRUE;
|
||||
}
|
||||
}
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
SECStatus
|
||||
isIssuerCertAllowedAtCertIssuanceTime(CERTCertificate *issuerCert,
|
||||
CERTCertificate *referenceCert)
|
||||
{
|
||||
if (!issuerCert || !referenceCert) {
|
||||
PORT_SetError(SEC_ERROR_INVALID_ARGS);
|
||||
return SECFailure;
|
||||
}
|
||||
|
||||
if (CertIsStartComOrWoSign(issuerCert)) {
|
||||
/* PRTime is microseconds since the epoch, whereas JS time is milliseconds.
|
||||
* (new Date("2016-10-21T00:00:00Z")).getTime() * 1000
|
||||
*/
|
||||
static const PRTime OCTOBER_21_2016 = 1477008000000000;
|
||||
|
||||
PRTime notBefore, notAfter;
|
||||
SECStatus rv;
|
||||
|
||||
rv = CERT_GetCertTimes(referenceCert, ¬Before, ¬After);
|
||||
if (rv != SECSuccess)
|
||||
return rv;
|
||||
|
||||
if (notBefore > OCTOBER_21_2016) {
|
||||
return SECFailure;
|
||||
}
|
||||
}
|
||||
|
||||
return SECSuccess;
|
||||
}
|
||||
|
||||
static SECStatus
|
||||
cert_VerifyCertChainOld(CERTCertDBHandle *handle, CERTCertificate *cert,
|
||||
PRBool checkSig, PRBool *sigerror,
|
||||
|
@ -615,6 +751,13 @@ cert_VerifyCertChainOld(CERTCertDBHandle *handle, CERTCertificate *cert,
|
|||
goto loser;
|
||||
}
|
||||
|
||||
rv = isIssuerCertAllowedAtCertIssuanceTime(issuerCert, cert);
|
||||
if (rv != SECSuccess) {
|
||||
PORT_SetError(SEC_ERROR_UNTRUSTED_ISSUER);
|
||||
LOG_ERROR(log, issuerCert, count + 1, 0);
|
||||
goto loser;
|
||||
}
|
||||
|
||||
/* XXX - the error logging may need to go down into CRL stuff at some
|
||||
* point
|
||||
*/
|
||||
|
|
|
@ -406,6 +406,11 @@
|
|||
'SHA_NO_LONG_LONG',
|
||||
],
|
||||
}],
|
||||
[ 'target_arch=="arm64"', {
|
||||
'defines': [
|
||||
'NSS_USE_64',
|
||||
],
|
||||
}],
|
||||
],
|
||||
}],
|
||||
],
|
||||
|
|
|
@ -160,7 +160,7 @@ RNG_kstat(PRUint32 *fed)
|
|||
|
||||
#endif
|
||||
|
||||
#if defined(SCO) || defined(UNIXWARE) || defined(BSDI) || defined(FREEBSD) || defined(NETBSD) || defined(DARWIN) || defined(OPENBSD) || defined(NTO) || defined(__riscos__)
|
||||
#if defined(SCO) || defined(UNIXWARE) || defined(BSDI) || defined(FREEBSD) || defined(NETBSD) || defined(DARWIN) || defined(OPENBSD) || defined(NTO) || defined(__riscos__) || defined(__GNU__) || defined(__FreeBSD_kernel__) || defined(__NetBSD_kernel__)
|
||||
#include <sys/times.h>
|
||||
|
||||
#define getdtablesize() sysconf(_SC_OPEN_MAX)
|
||||
|
|
|
@ -1095,4 +1095,5 @@ PKIX_ERRORENTRY(X500NAMEMATCHFAILED,PKIX_PL_X500Name_Match failed,0),
|
|||
PKIX_ERRORENTRY(X500NAMETOSTRINGFAILED,PKIX_PL_X500Name_ToString failed,0),
|
||||
PKIX_ERRORENTRY(ZEROLENGTHBYTEARRAYFORCRLENCODING,Zero-length ByteArray for CRL encoding,0),
|
||||
PKIX_ERRORENTRY(INVALIDOCSPHTTPMETHOD,Unsupported HTTP Method for OCSP retrieval,0),
|
||||
PKIX_ERRORENTRY(OCSPGETREQUESTTOOBIG,OCSP request too big for HTTP GET method,0)
|
||||
PKIX_ERRORENTRY(OCSPGETREQUESTTOOBIG,OCSP request too big for HTTP GET method,0),
|
||||
PKIX_ERRORENTRY(CERTISBLACKLISTEDATISSUANCETIME,Issuer Certificate is distrusted at the time the subordinate certifiate was issued,SEC_ERROR_UNTRUSTED_ISSUER)
|
||||
|
|
|
@ -1943,6 +1943,10 @@ pkix_PrepareForwardBuilderStateForAIA(
|
|||
state->status = BUILD_TRYAIA;
|
||||
}
|
||||
|
||||
extern SECStatus
|
||||
isIssuerCertAllowedAtCertIssuanceTime(CERTCertificate *issuerCert,
|
||||
CERTCertificate *referenceCert);
|
||||
|
||||
/*
|
||||
* FUNCTION: pkix_BuildForwardDepthFirstSearch
|
||||
* DESCRIPTION:
|
||||
|
@ -2057,6 +2061,7 @@ pkix_BuildForwardDepthFirstSearch(
|
|||
PKIX_ComCertSelParams *certSelParams = NULL;
|
||||
PKIX_TrustAnchor *trustAnchor = NULL;
|
||||
PKIX_PL_Cert *trustedCert = NULL;
|
||||
PKIX_PL_Cert *targetCert = NULL;
|
||||
PKIX_VerifyNode *verifyNode = NULL;
|
||||
PKIX_Error *verifyError = NULL;
|
||||
PKIX_Error *finalError = NULL;
|
||||
|
@ -2072,6 +2077,7 @@ pkix_BuildForwardDepthFirstSearch(
|
|||
validityDate = state->validityDate;
|
||||
canBeCached = state->canBeCached;
|
||||
PKIX_DECREF(*pValResult);
|
||||
targetCert = state->buildConstants.targetCert;
|
||||
|
||||
/*
|
||||
* We return if successful; if we fall off the end
|
||||
|
@ -2354,6 +2360,12 @@ pkix_BuildForwardDepthFirstSearch(
|
|||
plContext),
|
||||
PKIX_LISTGETITEMFAILED);
|
||||
|
||||
if (isIssuerCertAllowedAtCertIssuanceTime(
|
||||
state->candidateCert->nssCert, targetCert->nssCert)
|
||||
!= SECSuccess) {
|
||||
PKIX_ERROR(PKIX_CERTISBLACKLISTEDATISSUANCETIME);
|
||||
}
|
||||
|
||||
if ((state->verifyNode) != NULL) {
|
||||
PKIX_CHECK_FATAL(pkix_VerifyNode_Create
|
||||
(state->candidateCert,
|
||||
|
|
|
@ -612,6 +612,10 @@ PK11_GetKeyGenWithSize(CK_MECHANISM_TYPE type, int size)
|
|||
case CKM_NETSCAPE_PBE_SHA1_HMAC_KEY_GEN:
|
||||
case CKM_NETSCAPE_PBE_MD5_HMAC_KEY_GEN:
|
||||
case CKM_NETSCAPE_PBE_MD2_HMAC_KEY_GEN:
|
||||
case CKM_NSS_PKCS12_PBE_SHA224_HMAC_KEY_GEN:
|
||||
case CKM_NSS_PKCS12_PBE_SHA256_HMAC_KEY_GEN:
|
||||
case CKM_NSS_PKCS12_PBE_SHA384_HMAC_KEY_GEN:
|
||||
case CKM_NSS_PKCS12_PBE_SHA512_HMAC_KEY_GEN:
|
||||
case CKM_NETSCAPE_PBE_SHA1_DES_CBC:
|
||||
case CKM_NETSCAPE_PBE_SHA1_40_BIT_RC2_CBC:
|
||||
case CKM_NETSCAPE_PBE_SHA1_128_BIT_RC2_CBC:
|
||||
|
|
|
@ -1014,6 +1014,10 @@ secmod_getConfigDir(const char *spec, char **certPrefix, char **keyPrefix,
|
|||
*certPrefix = NULL;
|
||||
*keyPrefix = NULL;
|
||||
*readOnly = NSSUTIL_ArgHasFlag("flags", "readOnly", spec);
|
||||
if (NSSUTIL_ArgHasFlag("flags", "nocertdb", spec) ||
|
||||
NSSUTIL_ArgHasFlag("flags", "nokeydb", spec)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
spec = NSSUTIL_ArgStrip(spec);
|
||||
while (*spec) {
|
||||
|
@ -1133,6 +1137,13 @@ secmod_matchConfig(char *configDir1, char *configDir2,
|
|||
char *keyPrefix1, char *keyPrefix2,
|
||||
PRBool isReadOnly1, PRBool isReadOnly2)
|
||||
{
|
||||
/* TODO: Document the answer to the question:
|
||||
* "Why not allow them to match if they are both NULL?"
|
||||
* See: https://bugzilla.mozilla.org/show_bug.cgi?id=1318633#c1
|
||||
*/
|
||||
if ((configDir1 == NULL) || (configDir2 == NULL)) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
if (strcmp(configDir1, configDir2) != 0) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
@ -1169,7 +1180,6 @@ secmod_MatchConfigList(const char *spec, SECMODConfigList *conflist, int count)
|
|||
|
||||
config = secmod_getConfigDir(spec, &certPrefix, &keyPrefix, &isReadOnly);
|
||||
if (!config) {
|
||||
ret = PR_TRUE;
|
||||
goto done;
|
||||
}
|
||||
|
||||
|
|
|
@ -1335,11 +1335,23 @@ sec_pkcs12_decoder_verify_mac(SEC_PKCS12DecoderContext *p12dcx)
|
|||
case SEC_OID_MD2:
|
||||
integrityMech = CKM_NETSCAPE_PBE_MD2_HMAC_KEY_GEN;
|
||||
break;
|
||||
case SEC_OID_SHA224:
|
||||
integrityMech = CKM_NSS_PKCS12_PBE_SHA224_HMAC_KEY_GEN;
|
||||
break;
|
||||
case SEC_OID_SHA256:
|
||||
integrityMech = CKM_NSS_PKCS12_PBE_SHA256_HMAC_KEY_GEN;
|
||||
break;
|
||||
case SEC_OID_SHA384:
|
||||
integrityMech = CKM_NSS_PKCS12_PBE_SHA384_HMAC_KEY_GEN;
|
||||
break;
|
||||
case SEC_OID_SHA512:
|
||||
integrityMech = CKM_NSS_PKCS12_PBE_SHA512_HMAC_KEY_GEN;
|
||||
break;
|
||||
default:
|
||||
goto loser;
|
||||
}
|
||||
|
||||
symKey = PK11_KeyGen(NULL, integrityMech, params, 20, NULL);
|
||||
symKey = PK11_KeyGen(NULL, integrityMech, params, 0, NULL);
|
||||
PK11_DestroyPBEParams(params);
|
||||
params = NULL;
|
||||
if (!symKey)
|
||||
|
|
|
@ -706,6 +706,7 @@ NSS_CMSSignedData_VerifyCertsOnly(NSSCMSSignedData *sigd,
|
|||
int i;
|
||||
int count;
|
||||
PRTime now;
|
||||
void *pwarg = NULL;
|
||||
|
||||
if (!sigd || !certdb || !sigd->rawCerts) {
|
||||
PORT_SetError(SEC_ERROR_INVALID_ARGS);
|
||||
|
@ -724,8 +725,11 @@ NSS_CMSSignedData_VerifyCertsOnly(NSSCMSSignedData *sigd,
|
|||
break;
|
||||
}
|
||||
}
|
||||
if (sigd->cmsg) {
|
||||
pwarg = sigd->cmsg->pwfn_arg;
|
||||
}
|
||||
rv |= CERT_VerifyCert(certdb, cert, PR_TRUE, usage, now,
|
||||
NULL, NULL);
|
||||
pwarg, NULL);
|
||||
CERT_DestroyCertificate(cert);
|
||||
}
|
||||
|
||||
|
|
|
@ -408,7 +408,6 @@ loser:
|
|||
return result;
|
||||
}
|
||||
|
||||
#define HMAC_BUFFER 64
|
||||
#define NSSPBE_ROUNDUP(x, y) ((((x) + ((y)-1)) / (y)) * (y))
|
||||
#define NSSPBE_MIN(x, y) ((x) < (y) ? (x) : (y))
|
||||
/*
|
||||
|
@ -430,6 +429,7 @@ nsspkcs5_PKCS12PBE(const SECHashObject *hashObject,
|
|||
int iter;
|
||||
unsigned char *iterBuf;
|
||||
void *hash = NULL;
|
||||
unsigned int bufferLength;
|
||||
|
||||
arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE);
|
||||
if (!arena) {
|
||||
|
@ -439,8 +439,11 @@ nsspkcs5_PKCS12PBE(const SECHashObject *hashObject,
|
|||
/* how many hash object lengths are needed */
|
||||
c = (bytesNeeded + (hashLength - 1)) / hashLength;
|
||||
|
||||
/* 64 if 0 < hashLength <= 32, 128 if 32 < hashLength <= 64 */
|
||||
bufferLength = NSSPBE_ROUNDUP(hashLength * 2, 64);
|
||||
|
||||
/* initialize our buffers */
|
||||
D.len = HMAC_BUFFER;
|
||||
D.len = bufferLength;
|
||||
/* B and D are the same length, use one alloc go get both */
|
||||
D.data = (unsigned char *)PORT_ArenaZAlloc(arena, D.len * 2);
|
||||
B.len = D.len;
|
||||
|
@ -452,8 +455,8 @@ nsspkcs5_PKCS12PBE(const SECHashObject *hashObject,
|
|||
goto loser;
|
||||
}
|
||||
|
||||
SLen = NSSPBE_ROUNDUP(salt->len, HMAC_BUFFER);
|
||||
PLen = NSSPBE_ROUNDUP(pwitem->len, HMAC_BUFFER);
|
||||
SLen = NSSPBE_ROUNDUP(salt->len, bufferLength);
|
||||
PLen = NSSPBE_ROUNDUP(pwitem->len, bufferLength);
|
||||
I.len = SLen + PLen;
|
||||
I.data = (unsigned char *)PORT_ArenaZAlloc(arena, I.len);
|
||||
if (I.data == NULL) {
|
||||
|
|
|
@ -480,6 +480,10 @@ static const struct mechanismList mechanisms[] = {
|
|||
{ CKM_NETSCAPE_PBE_SHA1_HMAC_KEY_GEN, { 20, 20, CKF_GENERATE }, PR_TRUE },
|
||||
{ CKM_NETSCAPE_PBE_MD5_HMAC_KEY_GEN, { 16, 16, CKF_GENERATE }, PR_TRUE },
|
||||
{ CKM_NETSCAPE_PBE_MD2_HMAC_KEY_GEN, { 16, 16, CKF_GENERATE }, PR_TRUE },
|
||||
{ CKM_NSS_PKCS12_PBE_SHA224_HMAC_KEY_GEN, { 28, 28, CKF_GENERATE }, PR_TRUE },
|
||||
{ CKM_NSS_PKCS12_PBE_SHA256_HMAC_KEY_GEN, { 32, 32, CKF_GENERATE }, PR_TRUE },
|
||||
{ CKM_NSS_PKCS12_PBE_SHA384_HMAC_KEY_GEN, { 48, 48, CKF_GENERATE }, PR_TRUE },
|
||||
{ CKM_NSS_PKCS12_PBE_SHA512_HMAC_KEY_GEN, { 64, 64, CKF_GENERATE }, PR_TRUE },
|
||||
/* ------------------ AES Key Wrap (also encrypt) ------------------- */
|
||||
{ CKM_NETSCAPE_AES_KEY_WRAP, { 16, 32, CKF_EN_DE_WR_UN }, PR_TRUE },
|
||||
{ CKM_NETSCAPE_AES_KEY_WRAP_PAD, { 16, 32, CKF_EN_DE_WR_UN }, PR_TRUE },
|
||||
|
|
|
@ -3971,6 +3971,22 @@ nsc_SetupHMACKeyGen(CK_MECHANISM_PTR pMechanism, NSSPKCS5PBEParameter **pbe)
|
|||
params->hashType = HASH_AlgMD2;
|
||||
params->keyLen = 16;
|
||||
break;
|
||||
case CKM_NSS_PKCS12_PBE_SHA224_HMAC_KEY_GEN:
|
||||
params->hashType = HASH_AlgSHA224;
|
||||
params->keyLen = 28;
|
||||
break;
|
||||
case CKM_NSS_PKCS12_PBE_SHA256_HMAC_KEY_GEN:
|
||||
params->hashType = HASH_AlgSHA256;
|
||||
params->keyLen = 32;
|
||||
break;
|
||||
case CKM_NSS_PKCS12_PBE_SHA384_HMAC_KEY_GEN:
|
||||
params->hashType = HASH_AlgSHA384;
|
||||
params->keyLen = 48;
|
||||
break;
|
||||
case CKM_NSS_PKCS12_PBE_SHA512_HMAC_KEY_GEN:
|
||||
params->hashType = HASH_AlgSHA512;
|
||||
params->keyLen = 64;
|
||||
break;
|
||||
default:
|
||||
PORT_FreeArena(arena, PR_TRUE);
|
||||
return CKR_MECHANISM_INVALID;
|
||||
|
@ -4189,6 +4205,10 @@ NSC_GenerateKey(CK_SESSION_HANDLE hSession,
|
|||
case CKM_NETSCAPE_PBE_SHA1_HMAC_KEY_GEN:
|
||||
case CKM_NETSCAPE_PBE_MD5_HMAC_KEY_GEN:
|
||||
case CKM_NETSCAPE_PBE_MD2_HMAC_KEY_GEN:
|
||||
case CKM_NSS_PKCS12_PBE_SHA224_HMAC_KEY_GEN:
|
||||
case CKM_NSS_PKCS12_PBE_SHA256_HMAC_KEY_GEN:
|
||||
case CKM_NSS_PKCS12_PBE_SHA384_HMAC_KEY_GEN:
|
||||
case CKM_NSS_PKCS12_PBE_SHA512_HMAC_KEY_GEN:
|
||||
key_gen_type = nsc_pbe;
|
||||
key_type = CKK_GENERIC_SECRET;
|
||||
crv = nsc_SetupHMACKeyGen(pMechanism, &pbe_param);
|
||||
|
|
|
@ -183,7 +183,7 @@ extern PRBool sftk_fatalError;
|
|||
|
||||
#define CHECK_FORK_MIXED
|
||||
|
||||
#elif defined(LINUX)
|
||||
#elif defined(LINUX) || defined(__GLIBC__)
|
||||
|
||||
#define CHECK_FORK_PTHREAD
|
||||
|
||||
|
|
|
@ -68,6 +68,11 @@
|
|||
'UNSAFE_FUZZER_MODE',
|
||||
],
|
||||
}],
|
||||
[ 'mozilla_client==1', {
|
||||
'defines': [
|
||||
'NSS_ENABLE_TLS13_SHORT_HEADERS',
|
||||
],
|
||||
}],
|
||||
],
|
||||
'dependencies': [
|
||||
'<(DEPTH)/exports.gyp:nss_exports',
|
||||
|
|
|
@ -228,7 +228,7 @@ SSL_IMPORT PRFileDesc *DTLS_ImportFD(PRFileDesc *model, PRFileDesc *fd);
|
|||
* on the server to read that data. Calls to
|
||||
* SSL_GetPreliminaryChannelInfo() and SSL_GetNextProto()
|
||||
* can be made used during this period to learn about the channel
|
||||
* parameters [TODO(ekr@rtfm.com): This hasn't landed yet].
|
||||
* parameters.
|
||||
*
|
||||
* The transition between the 0-RTT and 1-RTT modes is marked by the
|
||||
* handshake callback.
|
||||
|
|
|
@ -2577,12 +2577,24 @@ ssl_ProtectRecord(sslSocket *ss, ssl3CipherSpec *cwSpec,
|
|||
const SSL3Opaque *pIn, PRUint32 contentLen, sslBuffer *wrBuf)
|
||||
{
|
||||
const ssl3BulkCipherDef *cipher_def = cwSpec->cipher_def;
|
||||
PRUint16 headerLen = IS_DTLS(ss) ? DTLS_RECORD_HEADER_LENGTH : SSL3_RECORD_HEADER_LENGTH;
|
||||
sslBuffer protBuf = { wrBuf->buf + headerLen, 0, wrBuf->space - headerLen };
|
||||
PRUint16 headerLen;
|
||||
sslBuffer protBuf;
|
||||
SSL3ProtocolVersion version = cwSpec->version;
|
||||
PRBool isTLS13;
|
||||
PRUint8 *ptr = wrBuf->buf;
|
||||
SECStatus rv;
|
||||
|
||||
if (ss->ssl3.hs.shortHeaders) {
|
||||
PORT_Assert(!IS_DTLS(ss));
|
||||
PORT_Assert(ss->version >= SSL_LIBRARY_VERSION_TLS_1_3);
|
||||
headerLen = TLS13_RECORD_HEADER_LENGTH_SHORT;
|
||||
} else {
|
||||
headerLen = IS_DTLS(ss) ? DTLS_RECORD_HEADER_LENGTH : SSL3_RECORD_HEADER_LENGTH;
|
||||
}
|
||||
protBuf.buf = wrBuf->buf + headerLen;
|
||||
protBuf.len = 0;
|
||||
protBuf.space = wrBuf->space - headerLen;
|
||||
|
||||
PORT_Assert(cipher_def->max_records <= RECORD_SEQ_MAX);
|
||||
if ((cwSpec->write_seq_num & RECORD_SEQ_MAX) >= cipher_def->max_records) {
|
||||
SSL_TRC(3, ("%d: SSL[-]: write sequence number at limit 0x%0llx",
|
||||
|
@ -2612,29 +2624,32 @@ ssl_ProtectRecord(sslSocket *ss, ssl3CipherSpec *cwSpec,
|
|||
PORT_Assert(protBuf.len <= MAX_FRAGMENT_LENGTH + (isTLS13 ? 256 : 1024));
|
||||
wrBuf->len = protBuf.len + headerLen;
|
||||
|
||||
if (ss->ssl3.hs.shortHeaders) {
|
||||
PORT_Assert(!IS_DTLS(ss)); /* Decoder not yet implemented. */
|
||||
(void)ssl_EncodeUintX(0x8000 | protBuf.len, 2, ptr);
|
||||
} else {
|
||||
#ifndef UNSAFE_FUZZER_MODE
|
||||
if (isTLS13 && cipher_def->calg != ssl_calg_null) {
|
||||
wrBuf->buf[0] = content_application_data;
|
||||
*ptr++ = content_application_data;
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
wrBuf->buf[0] = type;
|
||||
*ptr++ = type;
|
||||
}
|
||||
|
||||
if (IS_DTLS(ss)) {
|
||||
version = isTLS13 ? SSL_LIBRARY_VERSION_TLS_1_1 : version;
|
||||
version = dtls_TLSVersionToDTLSVersion(version);
|
||||
|
||||
(void)ssl_EncodeUintX(version, 2, &wrBuf->buf[1]);
|
||||
(void)ssl_EncodeUintX(cwSpec->write_seq_num, 8, &wrBuf->buf[3]);
|
||||
(void)ssl_EncodeUintX(protBuf.len, 2, &wrBuf->buf[11]);
|
||||
ptr = ssl_EncodeUintX(version, 2, ptr);
|
||||
ptr = ssl_EncodeUintX(cwSpec->write_seq_num, 8, ptr);
|
||||
} else {
|
||||
if (capRecordVersion || isTLS13) {
|
||||
version = PR_MIN(SSL_LIBRARY_VERSION_TLS_1_0, version);
|
||||
}
|
||||
|
||||
(void)ssl_EncodeUintX(version, 2, &wrBuf->buf[1]);
|
||||
(void)ssl_EncodeUintX(protBuf.len, 2, &wrBuf->buf[3]);
|
||||
ptr = ssl_EncodeUintX(version, 2, ptr);
|
||||
}
|
||||
(void)ssl_EncodeUintX(protBuf.len, 2, ptr);
|
||||
}
|
||||
++cwSpec->write_seq_num;
|
||||
|
||||
|
|
|
@ -39,6 +39,7 @@ static const ssl3ExtensionHandler clientHelloHandlers[] = {
|
|||
{ ssl_tls13_early_data_xtn, &tls13_ServerHandleEarlyDataXtn },
|
||||
{ ssl_tls13_psk_key_exchange_modes_xtn,
|
||||
&tls13_ServerHandlePskKeyExchangeModesXtn },
|
||||
{ ssl_tls13_short_header_xtn, &tls13_HandleShortHeaderXtn },
|
||||
{ -1, NULL }
|
||||
};
|
||||
|
||||
|
@ -58,6 +59,7 @@ static const ssl3ExtensionHandler serverHelloHandlersTLS[] = {
|
|||
{ ssl_tls13_key_share_xtn, &tls13_ClientHandleKeyShareXtn },
|
||||
{ ssl_tls13_pre_shared_key_xtn, &tls13_ClientHandlePreSharedKeyXtn },
|
||||
{ ssl_tls13_early_data_xtn, &tls13_ClientHandleEarlyDataXtn },
|
||||
{ ssl_tls13_short_header_xtn, &tls13_HandleShortHeaderXtn },
|
||||
{ -1, NULL }
|
||||
};
|
||||
|
||||
|
@ -115,6 +117,7 @@ static const ssl3HelloExtensionSender clientHelloSendersTLS[SSL_MAX_EXTENSIONS]
|
|||
* client hello is empty. They are not intolerant of TLS 1.2, so list
|
||||
* signature_algorithms at the end. See bug 1243641. */
|
||||
{ ssl_tls13_supported_versions_xtn, &tls13_ClientSendSupportedVersionsXtn },
|
||||
{ ssl_tls13_short_header_xtn, &tls13_SendShortHeaderXtn },
|
||||
{ ssl_signature_algorithms_xtn, &ssl3_ClientSendSigAlgsXtn },
|
||||
{ ssl_tls13_cookie_xtn, &tls13_ClientSendHrrCookieXtn },
|
||||
{ ssl_tls13_psk_key_exchange_modes_xtn,
|
||||
|
|
|
@ -97,7 +97,7 @@ ssl3_GatherData(sslSocket *ss, sslGather *gs, int flags, ssl2Gather *ssl2gs)
|
|||
PORT_Assert(ss->opt.noLocks || ssl_HaveRecvBufLock(ss));
|
||||
if (gs->state == GS_INIT) {
|
||||
gs->state = GS_HEADER;
|
||||
gs->remainder = 5;
|
||||
gs->remainder = ss->ssl3.hs.shortHeaders ? 2 : 5;
|
||||
gs->offset = 0;
|
||||
gs->writeOffset = 0;
|
||||
gs->readOffset = 0;
|
||||
|
@ -149,10 +149,22 @@ ssl3_GatherData(sslSocket *ss, sslGather *gs, int flags, ssl2Gather *ssl2gs)
|
|||
/* Check for SSLv2 handshakes. Always assume SSLv3 on clients,
|
||||
* support SSLv2 handshakes only when ssl2gs != NULL. */
|
||||
if (!ssl2gs || ssl3_isLikelyV3Hello(gs->hdr)) {
|
||||
/* Should have an SSLv3 record header in gs->hdr. Extract
|
||||
/* Should have a non-SSLv2 record header in gs->hdr. Extract
|
||||
* the length of the following encrypted data, and then
|
||||
* read in the rest of the SSL3 record into gs->inbuf. */
|
||||
* read in the rest of the record into gs->inbuf. */
|
||||
if (ss->ssl3.hs.shortHeaders) {
|
||||
PRUint16 len = (gs->hdr[0] << 8) | gs->hdr[1];
|
||||
if (!(len & 0x8000)) {
|
||||
SSL_DBG(("%d: SSL3[%d]: incorrectly formatted header"));
|
||||
SSL3_SendAlert(ss, alert_fatal, illegal_parameter);
|
||||
gs->state = GS_INIT;
|
||||
PORT_SetError(SSL_ERROR_BAD_MAC_READ);
|
||||
return SECFailure;
|
||||
}
|
||||
gs->remainder = len & ~0x8000;
|
||||
} else {
|
||||
gs->remainder = (gs->hdr[3] << 8) | gs->hdr[4];
|
||||
}
|
||||
} else {
|
||||
/* Probably an SSLv2 record header. No need to handle any
|
||||
* security escapes (gs->hdr[0] & 0x40) as we wouldn't get
|
||||
|
@ -458,8 +470,13 @@ ssl3_GatherCompleteHandshake(sslSocket *ss, int flags)
|
|||
* If it's a change cipher spec, alert, or handshake message,
|
||||
* ss->gs.buf.len will be 0 when ssl3_HandleRecord returns SECSuccess.
|
||||
*/
|
||||
if (ss->ssl3.hs.shortHeaders) {
|
||||
cText.type = content_application_data;
|
||||
cText.version = SSL_LIBRARY_VERSION_TLS_1_0;
|
||||
} else {
|
||||
cText.type = (SSL3ContentType)ss->gs.hdr[0];
|
||||
cText.version = (ss->gs.hdr[1] << 8) | ss->gs.hdr[2];
|
||||
}
|
||||
|
||||
if (IS_DTLS(ss)) {
|
||||
sslSequenceNumber seq_num;
|
||||
|
|
|
@ -32,6 +32,7 @@ typedef PRUint16 ssl3CipherSuite;
|
|||
#define SSL3_RANDOM_LENGTH 32
|
||||
|
||||
#define SSL3_RECORD_HEADER_LENGTH 5
|
||||
#define TLS13_RECORD_HEADER_LENGTH_SHORT 2
|
||||
|
||||
/* SSL3_RECORD_HEADER_LENGTH + epoch/sequence_number */
|
||||
#define DTLS_RECORD_HEADER_LENGTH 13
|
||||
|
|
|
@ -296,6 +296,7 @@ typedef struct sslOptionsStr {
|
|||
unsigned int enableSignedCertTimestamps : 1;
|
||||
unsigned int requireDHENamedGroups : 1;
|
||||
unsigned int enable0RttData : 1;
|
||||
unsigned int enableShortHeaders : 1;
|
||||
} sslOptions;
|
||||
|
||||
typedef enum { sslHandshakingUndetermined = 0,
|
||||
|
@ -874,6 +875,7 @@ typedef struct SSL3HandshakeStateStr {
|
|||
* or received. */
|
||||
ssl3KEADef kea_def_mutable; /* Used to hold the writable kea_def
|
||||
* we use for TLS 1.3 */
|
||||
PRBool shortHeaders; /* Assigned if we are doing short headers. */
|
||||
} SSL3HandshakeState;
|
||||
|
||||
/*
|
||||
|
|
|
@ -140,6 +140,9 @@ SSL_GetPreliminaryChannelInfo(PRFileDesc *fd,
|
|||
inf.valuesSet = ss->ssl3.hs.preliminaryInfo;
|
||||
inf.protocolVersion = ss->version;
|
||||
inf.cipherSuite = ss->ssl3.hs.cipher_suite;
|
||||
inf.canSendEarlyData = !ss->sec.isServer &&
|
||||
(ss->ssl3.hs.zeroRttState == ssl_0rtt_sent) &&
|
||||
!ss->firstHsDone;
|
||||
|
||||
memcpy(info, &inf, inf.length);
|
||||
return SECSuccess;
|
||||
|
|
Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше
Загрузка…
Ссылка в новой задаче