Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
strategy:
fail-fast: false
matrix:
node-version: [24.x, 23.x, 22.x, 21.x, 20.x, 19.x, 18.x, 17.x, 16.x]
node-version: [25.x, 24.x, 23.x, 22.x, 21.x, 20.x, 19.x, 18.x, 17.x, 16.x]
os: [windows-latest]
include:
- node-version: lts/*
Expand All @@ -35,6 +35,8 @@ jobs:
os: ubuntu-24.04-arm # Linux on arm64
- node-version: lts/*
os: windows-2025
- node-version: lts/*
os: windows-11-arm # Windows on arm64
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
Expand Down
11 changes: 0 additions & 11 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,6 @@ image:
environment:
NODE_GYP_FORCE_PYTHON: C:\Python39-x64\python.exe
matrix: # Test against these versions of Io.js and Node.js.
- nodejs_version: "24"
- nodejs_version: "23"
- nodejs_version: "22"
- nodejs_version: "22"
NODE_GYP_FORCE_PYTHON: C:\Python312-x64\python.exe
- nodejs_version: "21"
- nodejs_version: "20"
- nodejs_version: "19"
- nodejs_version: "18"
- nodejs_version: "17"
- nodejs_version: "16"
- nodejs_version: "14"
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
- nodejs_version: "12"
Expand Down
38 changes: 24 additions & 14 deletions nan.h
Original file line number Diff line number Diff line change
Expand Up @@ -427,15 +427,12 @@ template<typename P> class WeakCallbackInfo;

namespace imp {
static const size_t kMaxLength = 0x3fffffff;
// v8::String::REPLACE_INVALID_UTF8 was introduced
// in node.js v0.10.29 and v0.8.27.
#if NODE_MAJOR_VERSION > 0 || \
NODE_MINOR_VERSION > 10 || \
NODE_MINOR_VERSION == 10 && NODE_PATCH_VERSION >= 29 || \
NODE_MINOR_VERSION == 8 && NODE_PATCH_VERSION >= 27
static const unsigned kReplaceInvalidUtf8 = v8::String::REPLACE_INVALID_UTF8;
#if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 13 || \
(V8_MAJOR_VERSION == 13 && defined(V8_MINOR_VERSION) && V8_MINOR_VERSION >= 4))
static const unsigned kReplaceInvalidUtf8
= v8::String::WriteFlags::kReplaceInvalidUtf8;
#else
static const unsigned kReplaceInvalidUtf8 = 0;
static const unsigned kReplaceInvalidUtf8 = v8::String::REPLACE_INVALID_UTF8;
#endif
} // end of namespace imp

Expand Down Expand Up @@ -1167,11 +1164,18 @@ class Utf8String {
str_ = static_cast<char*>(malloc(len));
assert(str_ != 0);
}
const int flags =
v8::String::NO_NULL_TERMINATION | imp::kReplaceInvalidUtf8;
#if NODE_MAJOR_VERSION >= 11
length_ = string->WriteUtf8(v8::Isolate::GetCurrent(), str_,
#if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 13 || \
(V8_MAJOR_VERSION == 13 && defined(V8_MINOR_VERSION) && V8_MINOR_VERSION >= 4))
length_ = string->WriteUtf8V2(v8::Isolate::GetCurrent(), str_,
static_cast<int>(len), imp::kReplaceInvalidUtf8);
#else
const int flags =
v8::String::NO_NULL_TERMINATION | imp::kReplaceInvalidUtf8;
length_ = string->WriteUtf8(v8::Isolate::GetCurrent(), str_,
static_cast<int>(len), 0, flags);
#endif

#else
// See https://github.com/nodejs/nan/issues/832.
// Disable the warning as there is no way around it.
Expand All @@ -1183,7 +1187,9 @@ class Utf8String {
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif
length_ = string->WriteUtf8(str_, static_cast<int>(len), 0, flags);
const int flags =
v8::String::NO_NULL_TERMINATION | imp::kReplaceInvalidUtf8;
length_ = string->WriteUtf8(str_, static_cast<int>(len), 0, flags);
#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif
Expand Down Expand Up @@ -2626,7 +2632,9 @@ NAN_DEPRECATED inline void SetAccessor(
, getter_
, setter_
, obj
#if !defined(V8_MAJOR_VERSION) || V8_MAJOR_VERSION < 12
#if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION < 12 \
|| (V8_MAJOR_VERSION == 12 && defined(V8_MINOR_VERSION) \
&& V8_MINOR_VERSION == 0))
, settings
#endif
, attribute
Expand Down Expand Up @@ -2680,7 +2688,9 @@ inline void SetAccessor(
, getter_
, setter_
, obj
#if !defined(V8_MAJOR_VERSION) || V8_MAJOR_VERSION < 12
#if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION < 12 \
|| (V8_MAJOR_VERSION == 12 && defined(V8_MINOR_VERSION) \
&& V8_MINOR_VERSION == 0))
, settings
#endif
, attribute
Expand Down
6 changes: 5 additions & 1 deletion nan_maybe_43_inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,11 @@ inline Maybe<bool> SetPrototype(
, v8::Local<v8::Value> prototype) {
v8::Isolate *isolate = v8::Isolate::GetCurrent();
v8::HandleScope scope(isolate);
return obj->SetPrototype(isolate->GetCurrentContext(), prototype);
#if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION >= 14)
return obj->SetPrototypeV2(isolate->GetCurrentContext(), prototype);
#else
return obj->SetPrototype(isolate->GetCurrentContext(), prototype);
#endif
}

inline MaybeLocal<v8::String> ObjectProtoToString(
Expand Down