From 86e2b6cb0007c2d356e644937fcb516f0d048061 Mon Sep 17 00:00:00 2001 From: npaine Date: Fri, 23 Jan 2026 13:55:09 -0800 Subject: [PATCH] Adding support for putting the warning string at index of problem instead of at the beginning --- .../applications/events/Sanitizer.java | 18 ++++++++----- .../events/SanitizerConfiguration.java | 26 +++++++++++++++++++ lib/include/public/Version.hpp | 6 ++--- lib/jni/Sanitizer_jni.cpp | 5 +++- lib/modules | 2 +- wrappers/obj-c/ODWSanitizer.mm | 2 ++ wrappers/obj-c/ODWSanitizerInitConfig.h | 7 +++++ wrappers/obj-c/ODWSanitizerInitConfig.mm | 1 + .../OneDSSwift/SanitizerInitConfig.swift | 14 +++++++++- 9 files changed, 68 insertions(+), 13 deletions(-) diff --git a/lib/android_build/maesdk/src/main/java/com/microsoft/applications/events/Sanitizer.java b/lib/android_build/maesdk/src/main/java/com/microsoft/applications/events/Sanitizer.java index 6b40fb162..da58331de 100644 --- a/lib/android_build/maesdk/src/main/java/com/microsoft/applications/events/Sanitizer.java +++ b/lib/android_build/maesdk/src/main/java/com/microsoft/applications/events/Sanitizer.java @@ -18,15 +18,18 @@ public class Sanitizer { * 1 = SitePathStrict (enables strict site path analysis) * 2 = SitePathLoose (enables loose site path analysis) * Multiple flags can be combined with bitwise OR (e.g., 1 | 2 = 3) + * @param sendConcernLimit Maximum number of concerns to send. + * @param insertWarningAtProblemLocation Insert warnings at problem location (true) or prepend (false). * @return true if initialization was successful, false otherwise. */ - private static native boolean nativeInitialize(long loggerNativePtr, + private static native boolean nativeInitialize(long loggerNativePtr, String notificationEventName, - boolean enforceSanitization, - String[] urlDomains, - String[] emailDomains, + boolean enforceSanitization, + String[] urlDomains, + String[] emailDomains, int analyzerOptions, - int sendConcernLimit); + int sendConcernLimit, + boolean insertWarningAtProblemLocation); /** * Initializes the sanitizer with the provided configuration. * @@ -60,13 +63,14 @@ public static boolean initialize(SanitizerConfiguration config, String[] urlDoma } return nativeInitialize( - config.getLogger().getNativeILoggerPtr(), + config.getLogger().getNativeILoggerPtr(), config.getNotificationEventName(), config.isEnforceSanitization(), urlDomains, emailDomains, analyzerOptions, - sendConcernLimit); + sendConcernLimit, + config.isInsertWarningAtProblemLocation()); } /** diff --git a/lib/android_build/maesdk/src/main/java/com/microsoft/applications/events/SanitizerConfiguration.java b/lib/android_build/maesdk/src/main/java/com/microsoft/applications/events/SanitizerConfiguration.java index fa1dbd56b..ee01ed9dd 100644 --- a/lib/android_build/maesdk/src/main/java/com/microsoft/applications/events/SanitizerConfiguration.java +++ b/lib/android_build/maesdk/src/main/java/com/microsoft/applications/events/SanitizerConfiguration.java @@ -28,6 +28,14 @@ public class SanitizerConfiguration { */ private boolean enforceSanitization = true; + /** + * Flag to control where warning messages are inserted. + * When true, warnings are inserted at the problem location. + * When false (default), warnings are prepended to the beginning. + * Optional. Defaults to false. + */ + private boolean insertWarningAtProblemLocation = false; + /** * Constructs a new SanitizerConfiguration with the specified logger. * @@ -71,4 +79,22 @@ public boolean isEnforceSanitization() { public void setEnforceSanitization(boolean enforceSanitization) { this.enforceSanitization = enforceSanitization; } + + /** + * Returns whether warnings are inserted at the problem location. + * + * @return true if warnings are inserted at problem location, false if prepended + */ + public boolean isInsertWarningAtProblemLocation() { + return insertWarningAtProblemLocation; + } + + /** + * Sets whether warnings should be inserted at the problem location. + * + * @param insertAtLocation true to insert at problem location, false to prepend + */ + public void setInsertWarningAtProblemLocation(boolean insertAtLocation) { + this.insertWarningAtProblemLocation = insertAtLocation; + } } \ No newline at end of file diff --git a/lib/include/public/Version.hpp b/lib/include/public/Version.hpp index c78c5099b..e9eca7137 100644 --- a/lib/include/public/Version.hpp +++ b/lib/include/public/Version.hpp @@ -6,8 +6,8 @@ #define MAT_VERSION_HPP // WARNING: DO NOT MODIFY THIS FILE! // This file has been automatically generated, manual changes will be lost. -#define BUILD_VERSION_STR "3.10.20.1" -#define BUILD_VERSION 3,10,20,1 +#define BUILD_VERSION_STR "3.10.23.1" +#define BUILD_VERSION 3,10,23,1 #ifndef RESOURCE_COMPILER_INVOKED #include "ctmacros.hpp" @@ -18,7 +18,7 @@ namespace MAT_NS_BEGIN { uint64_t const Version = ((uint64_t)3 << 48) | ((uint64_t)10 << 32) | - ((uint64_t)20 << 16) | + ((uint64_t)23 << 16) | ((uint64_t)1); } MAT_NS_END diff --git a/lib/jni/Sanitizer_jni.cpp b/lib/jni/Sanitizer_jni.cpp index d4e29c2b4..38da2e39a 100644 --- a/lib/jni/Sanitizer_jni.cpp +++ b/lib/jni/Sanitizer_jni.cpp @@ -37,6 +37,7 @@ Java_com_microsoft_applications_events_Sanitizer_isInitialized(const JNIEnv *env * 2 = SitePathLoose (enables loose site path analysis) * Multiple flags can be combined with bitwise OR (e.g., 1 | 2 = 3) * @param sendConcernLimit Maximum number of concerns to send. 0 = no concerns sent, 65536+ = all concerns sent. + * @param insertWarningAtProblemLocation Insert warnings at problem location (true) or prepend (false). * **/ extern "C" JNIEXPORT jboolean JNICALL @@ -48,7 +49,8 @@ Java_com_microsoft_applications_events_Sanitizer_isInitialized(const JNIEnv *env jobjectArray urlDomains, jobjectArray emailDomains, jint analyzerOptions, - jint sendConcernLimit // number of concerns to upload. Set to 0 to upload none, greater than 65536 uploads everything. + jint sendConcernLimit, // number of concerns to upload. Set to 0 to upload none, greater than 65536 uploads everything. + jboolean insertWarningAtProblemLocation ) { if (spSanitizer != nullptr) { @@ -89,6 +91,7 @@ Java_com_microsoft_applications_events_Sanitizer_isInitialized(const JNIEnv *env } sanitizerConfig.SetAllWarningsToSanitizations = static_cast(warningsToSanitization); + sanitizerConfig.InsertWarningAtProblemLocation = static_cast(insertWarningAtProblemLocation); spSanitizer = std::make_shared(sanitizerConfig); return true; diff --git a/lib/modules b/lib/modules index c6f3f6c35..b38ffca2b 160000 --- a/lib/modules +++ b/lib/modules @@ -1 +1 @@ -Subproject commit c6f3f6c35543add52764fe70b93b19b08a6e85f7 +Subproject commit b38ffca2b25413ea56b4488076e3b0074720ea0f diff --git a/wrappers/obj-c/ODWSanitizer.mm b/wrappers/obj-c/ODWSanitizer.mm index 654298b8b..8f5517cea 100644 --- a/wrappers/obj-c/ODWSanitizer.mm +++ b/wrappers/obj-c/ODWSanitizer.mm @@ -35,6 +35,7 @@ +(void)initializeSanitizer:(ILogger *)logger withODWSanitizerInitConfig:(ODWSani } config.SetAllWarningsToSanitizations = initConfigObject.setWarningsToSanitization; config.SendConcernLimit = static_cast(initConfigObject.sendConcernLimit); + config.InsertWarningAtProblemLocation = initConfigObject.insertWarningAtProblemLocation; _sanitizerPtr = std::make_shared(config); LogManager::GetInstance()->SetDataInspector(_sanitizerPtr); @@ -73,6 +74,7 @@ +(void)initializeSanitizer:(ILogger *)logger withODWSanitizerInitConfig:(ODWSani } config.SetAllWarningsToSanitizations = initConfigObject.setWarningsToSanitization; config.SendConcernLimit = static_cast(initConfigObject.sendConcernLimit); + config.InsertWarningAtProblemLocation = initConfigObject.insertWarningAtProblemLocation; _sanitizerPtr = std::make_shared(config); LogManager::GetInstance()->SetDataInspector(_sanitizerPtr); diff --git a/wrappers/obj-c/ODWSanitizerInitConfig.h b/wrappers/obj-c/ODWSanitizerInitConfig.h index 2306ca033..ec915b673 100644 --- a/wrappers/obj-c/ODWSanitizerInitConfig.h +++ b/wrappers/obj-c/ODWSanitizerInitConfig.h @@ -26,6 +26,13 @@ NS_ASSUME_NONNULL_BEGIN */ @property(readwrite, nonatomic) NSUInteger sendConcernLimit; +/*! + @brief (OPTIONAL) When YES, warning messages are inserted at the problem location. + When NO (default), warnings are prepended to the beginning of the string. + Default value is `NO`. + */ +@property(readwrite, nonatomic) BOOL insertWarningAtProblemLocation; + // Initializer - (instancetype)init; diff --git a/wrappers/obj-c/ODWSanitizerInitConfig.mm b/wrappers/obj-c/ODWSanitizerInitConfig.mm index f3f668a97..79797d0d9 100644 --- a/wrappers/obj-c/ODWSanitizerInitConfig.mm +++ b/wrappers/obj-c/ODWSanitizerInitConfig.mm @@ -16,6 +16,7 @@ - (instancetype)init { _notificationEventName = @"SanitizerConcerns"; // Default event name _setWarningsToSanitization = YES; // Default to true _sendConcernLimit = 65536; // Default to 65536 (upload all concerns) + _insertWarningAtProblemLocation = NO; // Default to NO (prepend warnings) } return self; } diff --git a/wrappers/swift/Sources/OneDSSwift/SanitizerInitConfig.swift b/wrappers/swift/Sources/OneDSSwift/SanitizerInitConfig.swift index a8ea991f3..5b5ca7b8d 100644 --- a/wrappers/swift/Sources/OneDSSwift/SanitizerInitConfig.swift +++ b/wrappers/swift/Sources/OneDSSwift/SanitizerInitConfig.swift @@ -32,7 +32,19 @@ public final class SanitizerInitConfig { odwSanitizerInitConfig.setWarningsToSanitization = newValue } } - + + /// (OPTIONAL) When true, warnings are inserted at the problem location. + /// When false (default), warnings are prepended to the beginning of the string. + /// Default value is `false`. + public var insertWarningAtProblemLocation: Bool { + get { + odwSanitizerInitConfig.insertWarningAtProblemLocation + } + set { + odwSanitizerInitConfig.insertWarningAtProblemLocation = newValue + } + } + /** Returns the Obj-C object of the wrapper.