GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — src: do not run IsWindowsBatchFile on non-windows · nodejs/node@016baae

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • src
    • process_wrap.cc
    • spawn_sync.cc
    • util-inl.h
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/process_wrap.cc‎

Copy file name to clipboardExpand all lines: src/process_wrap.cc
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,10 @@ class ProcessWrap : public HandleWrap {
200200
// batch files directly but is potentially insecure because arguments
201201
// are not escaped (and sometimes cannot be unambiguously escaped),
202202
// hence why they are rejected here.
203+
#ifdef _WIN32
203204
if (IsWindowsBatchFile(options.file))
204205
err = UV_EINVAL;
206+
#endif
205207

206208
// options.args
207209
Local<Value> argv_v =
Collapse file

‎src/spawn_sync.cc‎

Copy file name to clipboardExpand all lines: src/spawn_sync.cc
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -769,8 +769,10 @@ Maybe<int> SyncProcessRunner::ParseOptions(Local<Value> js_value) {
769769
// batch files directly but is potentially insecure because arguments
770770
// are not escaped (and sometimes cannot be unambiguously escaped),
771771
// hence why they are rejected here.
772+
#ifdef _WIN32
772773
if (IsWindowsBatchFile(uv_process_options_.file))
773774
return Just<int>(UV_EINVAL);
775+
#endif
774776

775777
Local<Value> js_args =
776778
js_options->Get(context, env()->args_string()).ToLocalChecked();
Collapse file

‎src/util-inl.h‎

Copy file name to clipboardExpand all lines: src/util-inl.h
+13-17Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -540,25 +540,21 @@ constexpr std::string_view FastStringKey::as_string_view() const {
540540
// Inline so the compiler can fully optimize it away on Unix platforms.
541541
bool IsWindowsBatchFile(const char* filename) {
542542
#ifdef _WIN32
543-
static constexpr bool kIsWindows = true;
544-
#else
545-
static constexpr bool kIsWindows = false;
546-
#endif // _WIN32
547-
if (kIsWindows) {
548-
std::string file_with_extension = filename;
549-
// Regex to match the last extension part after the last dot, ignoring
550-
// trailing spaces and dots
551-
std::regex extension_regex(R"(\.([a-zA-Z0-9]+)\s*[\.\s]*$)");
552-
std::smatch match;
553-
std::string extension;
554-
555-
if (std::regex_search(file_with_extension, match, extension_regex)) {
556-
extension = ToLower(match[1].str());
557-
}
558-
559-
return !extension.empty() && (extension == "cmd" || extension == "bat");
543+
std::string file_with_extension = filename;
544+
// Regex to match the last extension part after the last dot, ignoring
545+
// trailing spaces and dots
546+
std::regex extension_regex(R"(\.([a-zA-Z0-9]+)\s*[\.\s]*$)");
547+
std::smatch match;
548+
std::string extension;
549+
550+
if (std::regex_search(file_with_extension, match, extension_regex)) {
551+
extension = ToLower(match[1].str());
560552
}
553+
554+
return !extension.empty() && (extension == "cmd" || extension == "bat");
555+
#else
561556
return false;
557+
#endif // _WIN32
562558
}
563559

564560
} // namespace node

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.