Yuliia7-1 commented on issue #12506:
URL: https://github.com/apache/cloudstack/issues/12506#issuecomment-3818433366

   Hi @DaanHoogland 
   What if we used a regex that already covers most possible cases? I 
understand it’s impossible to cover all edge cases, but the regex below should 
handle ~99% of them, shouldn’t it?
   
   The main concern, of course, is that we’d need to sanitize all fields across 
all endpoints. Trimming only some fields would feel a bit odd and could lead to 
seemingly random behavior. Our primary use case here is proper sorting and 
searching when querying the ACS API. If a field contains leading whitespace or 
invisible characters, sorting breaks completely and can become very confusing.
   
   ```
   // Matches Separators (Z), Control (C), and Format (Cf - e.g. Zero Width 
Space)
   private static final Pattern STRICT_LEADING =
       Pattern.compile("^[\\p{Z}\\p{C}\\p{Cf}]+");
   ```


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

Reply via email to