Mask the substring in range [start, end) of the given string value. Using rules in 'MaskTransform'. Indices are counted in bytes.
| 94 | /// Mask the substring in range [start, end) of the given string value. Using rules in |
| 95 | /// 'MaskTransform'. Indices are counted in bytes. |
| 96 | static StringVal MaskSubStr(FunctionContext* ctx, const StringVal& val, |
| 97 | int start, int end, int masked_upper_char, int masked_lower_char, |
| 98 | int masked_digit_char, int masked_other_char) { |
| 99 | DCHECK_GE(start, 0); |
| 100 | DCHECK_LT(start, end); |
| 101 | DCHECK_LE(end, val.len); |
| 102 | StringVal result(ctx, val.len); |
| 103 | if (UNLIKELY(result.is_null)) return StringVal::null(); |
| 104 | Ubsan::MemCpy(result.ptr, val.ptr, start); |
| 105 | if (end < val.len) Ubsan::MemCpy(result.ptr + end, val.ptr + end, val.len - end); |
| 106 | for (int i = start; i < end; ++i) { |
| 107 | result.ptr[i] = MaskTransform(val.ptr[i], masked_upper_char, masked_lower_char, |
| 108 | masked_digit_char, masked_other_char); |
| 109 | } |
| 110 | return result; |
| 111 | } |
| 112 | |
| 113 | /// Checks whether the unicode code point is malformed, i.e. illegal or incomplete, and |
| 114 | /// warns if it is. Returns true if any warning is added. |
no test coverage detected