moomindani opened a new issue, #15631:
URL: https://github.com/apache/iceberg/issues/15631

   ### Apache Iceberg version
   
   main (latest)
   
   ### Query engine
   
   Any
   
   ### Please describe the bug 🐞
   
   `PropertyUtil.propertiesWithPrefix` uses `String.replaceFirst(prefix, "")` 
to strip the prefix from matched keys. Since `replaceFirst` treats its first 
argument as a Java regex pattern, prefixes containing regex-special characters 
(e.g. `[`, `(`, `+`, `$`) cause incorrect behavior:
   
   1. **Silent mismatch**: A prefix like `prefix[0].` is valid regex where 
`[0]` matches char `0` and `.` matches any char. After `startsWith` filtering, 
the key always starts with the literal prefix, but `replaceFirst` fails to 
match the regex at position 0, silently returning the full key instead of 
stripping the prefix.
   
   2. **PatternSyntaxException**: A prefix like `prefix[0.` contains an 
unclosed character class, causing `replaceFirst` to throw 
`PatternSyntaxException`.
   
   The fix is to replace `replaceFirst(prefix, "")` with 
`substring(prefix.length())`, which is safe, explicit, and consistent with the 
`startsWith(prefix)` filter applied immediately before.
   
   Discovered while investigating #15347.


-- 
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