Skip to content

Commit 1f24267

Browse files
committed
fixup! fs: fix crash when path contains %
1 parent d39f385 commit 1f24267

File tree

1 file changed

+11
-14
lines changed

1 file changed

+11
-14
lines changed

src/node_file.cc

+11-14
Original file line numberDiff line numberDiff line change
@@ -3180,21 +3180,22 @@ static void CpSyncCheckPaths(const FunctionCallbackInfo<Value>& args) {
31803180
// Check if src and dest are identical.
31813181
if (std::filesystem::equivalent(src_path, dest_path)) {
31823182
std::string message = "src and dest cannot be the same %s";
3183-
return THROW_ERR_FS_CP_EINVAL(
3184-
env, message.c_str(), dest_path.string());
3183+
return THROW_ERR_FS_CP_EINVAL(env, message.c_str(), dest_path.string());
31853184
}
31863185

31873186
const bool dest_is_dir =
31883187
dest_status.type() == std::filesystem::file_type::directory;
31893188

31903189
if (src_is_dir && !dest_is_dir) {
3191-
std::string message = "Cannot overwrite non-directory %s with directory %s";
3190+
std::string message =
3191+
"Cannot overwrite non-directory %s with directory %s";
31923192
return THROW_ERR_FS_CP_DIR_TO_NON_DIR(
31933193
env, message.c_str(), src_path.string(), dest_path.string());
31943194
}
31953195

31963196
if (!src_is_dir && dest_is_dir) {
3197-
std::string message = "Cannot overwrite directory %s with non-directory %s";
3197+
std::string message =
3198+
"Cannot overwrite directory %s with non-directory %s";
31983199
return THROW_ERR_FS_CP_NON_DIR_TO_DIR(
31993200
env, message.c_str(), dest_path.string(), src_path.string());
32003201
}
@@ -3234,27 +3235,23 @@ static void CpSyncCheckPaths(const FunctionCallbackInfo<Value>& args) {
32343235
}
32353236

32363237
if (src_is_dir && !recursive) {
3237-
std::string message = "Recursive option not enabled, cannot copy a directory: %s";
3238-
return THROW_ERR_FS_EISDIR(env,
3239-
message.c_str(),
3240-
src_path_str);
3238+
std::string message =
3239+
"Recursive option not enabled, cannot copy a directory: %s";
3240+
return THROW_ERR_FS_EISDIR(env, message.c_str(), src_path_str);
32413241
}
32423242

32433243
switch (src_status.type()) {
32443244
case std::filesystem::file_type::socket: {
32453245
std::string message = "Cannot copy a socket file: %s";
3246-
return THROW_ERR_FS_CP_SOCKET(
3247-
env, message.c_str(), dest_path_str);
3246+
return THROW_ERR_FS_CP_SOCKET(env, message.c_str(), dest_path_str);
32483247
}
32493248
case std::filesystem::file_type::fifo: {
32503249
std::string message = "Cannot copy a FIFO pipe: %s";
3251-
return THROW_ERR_FS_CP_FIFO_PIPE(
3252-
env, message.c_str(), dest_path_str);
3250+
return THROW_ERR_FS_CP_FIFO_PIPE(env, message.c_str(), dest_path_str);
32533251
}
32543252
case std::filesystem::file_type::unknown: {
32553253
std::string message = "Cannot copy an unknown file type: %s";
3256-
return THROW_ERR_FS_CP_UNKNOWN(
3257-
env, message.c_str(), dest_path_str);
3254+
return THROW_ERR_FS_CP_UNKNOWN(env, message.c_str(), dest_path_str);
32583255
}
32593256
default:
32603257
break;

0 commit comments

Comments
 (0)