924060929 commented on code in PR #70924:
URL: https://github.com/apache/doris/pull/70924#discussion_r4735756311
##########
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:
`#71115` has already been merged into `master`: it reverted
`NereidsParser.parseForEncryption` back to returning inclusive code-point
positions so `BaseViewInfo.rewriteSql` performs the single code-point -> UTF-16
conversion for all callers (including `StreamingInsertJob` and
`StreamingInsertTask`, which also pass `parseForEncryption` ranges to
`BaseViewInfo.rewriteSql` and would still double-convert under the previous
contract).
With `#71115` on `master`, slicing `sql` directly by `range.first` /
`range.second` here results in **zero** conversions and shifts replacements
after supplementary characters again.
Please rebase onto `master`, revert `NeedAuditEncryption.java` to keep
calling `BaseViewInfo.rewriteSql(indexInSqlToString, sql)`, and align
`EncryptSQLTest` with `testEncryptionParserReturnsCodePointRanges` from
`#71115`.
--
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]