Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RestrictionValidator.validatePattern: invalid matching+ typo #2

Closed
d6c8 opened this issue May 17, 2021 · 2 comments
Closed

RestrictionValidator.validatePattern: invalid matching+ typo #2

d6c8 opened this issue May 17, 2021 · 2 comments

Comments

@d6c8
Copy link

d6c8 commented May 17, 2021

This method is defined as:

public static void validatePattern(String pattern, String string){
        if (!string.replaceAll(pattern, "").equals(string)){
            throw new RestrictionViolationException("Violation of pattern restriction, the string doesn't math the acceptable pattern, which is " + pattern);
        }
    }

It fails in the following scenario:

    // ...
    link().attrSizes("16x16").__()
   // ...
  1. It should probably be:
 if (!string.replaceAll(pattern, "").equals("")){

There are probably more efficient solutions to check matching, such as:

 if (!Pattern.matches(pattern, string)){
  1. doesn't math should be doesn't match
@d6c8 d6c8 changed the title RestrictionValidator.validatePattern RestrictionValidator.validatePattern: invalid matching+ typo May 17, 2021
@lcduarte
Copy link
Member

Hello,

Thanks for using the library and for the suggestion!

Added your fixes and deployed the 1.0.7 version.

@d6c8
Copy link
Author

d6c8 commented May 24, 2021

Thanks, I'm currently experimenting different solutions to generate HTML and will keep you informed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants