Skip to content

Commit a74dae8

Browse files
author
Nitin Chaudhary
committed
Address Copilot AI review comments
- FileReaderModule: Make allowedEncodings static const (performance) - BlobModule: Fix comment to match actual behavior (no logging) - InspectorPackagerConnection: Throw on validation failure instead of continuing - Improves security and code clarity
1 parent 19b8899 commit a74dae8

3 files changed

Lines changed: 4 additions & 4 deletions

File tree

vnext/Shared/InspectorPackagerConnection.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ InspectorPackagerConnection::InspectorPackagerConnection(
151151
} catch (const Microsoft::ReactNative::InputValidation::ValidationException &ex) {
152152
std::string errorMsg = std::string("Inspector URL validation failed: ") + ex.what();
153153
facebook::react::tracing::error(errorMsg.c_str());
154-
// Continue with invalid URL - error will be caught on connection attempt
154+
throw; // Prevent construction with invalid URL
155155
}
156156
}
157157

vnext/Shared/Modules/BlobModule.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ void BlobTurboModule::Release(string &&blobId) noexcept {
124124
Microsoft::ReactNative::InputValidation::PathValidator::ValidateBlobId(blobId);
125125
m_resource->Release(std::move(blobId));
126126
} catch (const Microsoft::ReactNative::InputValidation::ValidationException &) {
127-
// Log but don't propagate - release is best-effort
127+
// Silently ignore validation errors - release is best-effort and non-critical
128128
}
129129
}
130130

vnext/Shared/Modules/FileReaderModule.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ void FileReaderTurboModule::ReadAsText(
103103

104104
// SDL Compliance: Validate encoding (P1 - CVSS 5.5)
105105
try {
106-
// Allowlist of safe encodings
107-
std::vector<std::string> allowedEncodings = {
106+
// Allowlist of safe encodings (static to avoid repeated allocations)
107+
static const std::vector<std::string> allowedEncodings = {
108108
"UTF-8",
109109
"utf-8",
110110
"utf8",

0 commit comments

Comments
 (0)