Gabriel39 commented on code in PR #70924:
URL: https://github.com/apache/doris/pull/70924#discussion_r4736400915


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/NeedAuditEncryption.java:
##########
@@ -44,6 +44,15 @@ static String maskSql(String sql, boolean 
preserveFormatting) {
         TreeMap<Pair<Integer, Integer>, String> indexInSqlToString = new 
TreeMap<>(new Pair.PairComparator<>());
         NereidsParser parser = new NereidsParser();
         parser.parseForEncryption(sql, indexInSqlToString, preserveFormatting);
-        return BaseViewInfo.rewriteSql(indexInSqlToString, sql);
+        // parseForEncryption already returns UTF-16 offsets. Applying the 
view rewriter's
+        // code-point conversion again shifts masks after supplementary 
characters such as emoji.
+        StringBuilder result = new StringBuilder(sql.length());
+        int offset = 0;
+        for (Map.Entry<Pair<Integer, Integer>, String> entry : 
indexInSqlToString.entrySet()) {
+            Pair<Integer, Integer> range = entry.getKey();
+            result.append(sql, offset, range.first).append(entry.getValue());
+            offset = range.second + 1;
+        }
+        return result.append(sql, offset, sql.length()).toString();

Review Comment:
   Fixed in b5e14e6c4533.
   
   Integrated current master, including #71115, and restored 
`NeedAuditEncryption.maskSql` to call `BaseViewInfo.rewriteSql`. The parser 
continues to return inclusive code-point ranges, and the shared rewriter 
performs the single conversion to UTF-16 for masking, streaming and view 
callers.
   
   `testEncryptionParserReturnsCodePointRanges` now checks the shared rewriter 
and the public masking entry point in both formatting modes. On the integrated 
baseline, 20 of 25 `EncryptSQLTest` cases failed with shifted replacements and 
retained credential suffixes. With the fix, all 179 related tests in nine 
suites pass through `run-fe-ut.sh`, with zero failures, errors or skips; FE 
Checkstyle also passes. Live SQL/log and Docker regression were not rerun in 
this follow-up.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to