Page MenuHomePhorge

D14857.1765085820.diff
No OneTemporary

Size
2 KB
Referenced Files
None
Subscribers
None

D14857.1765085820.diff

diff --git a/lib/utils/validation-utils.js b/lib/utils/validation-utils.js
--- a/lib/utils/validation-utils.js
+++ b/lib/utils/validation-utils.js
@@ -108,6 +108,8 @@
const ashoatKeyserverID = '256';
+// Should be in sync with native/cpp/CommonCpp/NativeModules/\
+// PersistentStorageUtilities/ThreadOperationsUtilities/ThreadTypeEnum.h
const uuidRegex =
'[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}';
const idSchemaRegex = `(?:(?:[0-9]+|${uuidRegex})\\|)?(?:[0-9]+|${uuidRegex})`;
diff --git a/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/ThreadOperationsUtilities/ThreadTypeEnum.h b/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/ThreadOperationsUtilities/ThreadTypeEnum.h
--- a/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/ThreadOperationsUtilities/ThreadTypeEnum.h
+++ b/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/ThreadOperationsUtilities/ThreadTypeEnum.h
@@ -1,5 +1,7 @@
#pragma once
+#import <regex>
+#import <string>
#import <vector>
namespace comm {
@@ -28,4 +30,27 @@
ThreadType::PRIVATE,
ThreadType::THICK_SIDEBAR};
+// Regex patterns - should be in sync with lib/utils/validation-utils.js
+const std::string UUID_REGEX_STRING =
+ "[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{"
+ "12}";
+const std::string ID_SCHEMA_REGEX_STRING = "(?:(?:[0-9]+|" + UUID_REGEX_STRING +
+ ")\\|)?(?:[0-9]+|" + UUID_REGEX_STRING + ")";
+
+const std::regex IS_SCHEMA_REGEX("^" + ID_SCHEMA_REGEX_STRING + "$");
+const std::regex THICK_ID_REGEX("^" + UUID_REGEX_STRING + "$");
+
+// Helper functions for regex testing
+inline bool isSchemaID(const std::string &threadID) {
+ return std::regex_match(threadID, IS_SCHEMA_REGEX);
+}
+
+inline bool isThickID(const std::string &threadID) {
+ return std::regex_match(threadID, THICK_ID_REGEX);
+}
+
+inline bool threadIDMatchesKeyserverProtocol(const std::string &threadID) {
+ return isSchemaID(threadID) && !isThickID(threadID);
+}
+
} // namespace comm
diff --git a/web/shared-worker/_generated/comm_query_executor.wasm b/web/shared-worker/_generated/comm_query_executor.wasm
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
GIT binary patch
literal 0
Hc$@<O00001
literal 0
Hc$@<O00001

File Metadata

Mime Type
text/plain
Expires
Sun, Dec 7, 5:37 AM (11 h, 30 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5842624
Default Alt Text
D14857.1765085820.diff (2 KB)

Event Timeline