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

Allow null matcher group values in regex function #49

merged 2 commits into from Jul 20, 2016


Copy link

@lennartkoopmann lennartkoopmann commented Jul 20, 2016

Imagine you have a regular expression that is matching an IP address and a port. UDP and TCP will always have the port but ICMP will be missing the port.

The way to solve this is to have an optional matcher group that might match nothing in case of ICMP and end up with a null value in the matcher group results.

The problem is that we are using a ImmutableMap to store the matcher group values and a ImmutableMap does not allow null as value. This means that the regex function will always fail in case of ICMP packages but the port matcher group has a null value.

This pull request avoids adding a null value to the ImmutableMap. The order of matchers is still intact because we use the group match name or index as key of the map.

I found and (hopefully) fixed and actual issue in the year 2016. (7/19 may we never forget)

Copy link

@kroepke kroepke commented Jul 20, 2016

thanks, lgtm

@kroepke kroepke merged commit ac3fdd1 into master Jul 20, 2016
@kroepke kroepke deleted the fix-null-regex-matchers branch Jul 20, 2016
Copy link
Member Author

@lennartkoopmann lennartkoopmann commented Jul 20, 2016

Thanks for adding the test! :) I looked for regex tests but could not find them. (txt not java, now I know)

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

Successfully merging this pull request may close these issues.

None yet

2 participants