- marked as bug
Possible crash when regular expression not matched
Not in all cases an operation stops if the regular expression is not matched. For example, getParameter
in ClassViewHandler just calls find()
followed by calls to group(...)
. If the regular expression is not matched, an exception will be thrown.
The current implementations seem to do too much (i.e., pattern matches, then compile, find and then group calls). I think in general (for all usages of pattern matching) the following implementation should be used:
Matcher matcher = Pattern.compile(thePattern).matcher(theString);
if (!matcher.matches) {
// throw illegal argument exception
}
// do your stuff (i.e., get groups by calling matcher.group(...)
Comments (6)
-
reporter -
reporter -
assigned issue to
- marked as major
- changed component to GUI
-
assigned issue to
-
reporter Issue
#197was marked as a duplicate of this issue. -
reporter - changed status to resolved
Resolved issue
#93: Changed all occurrences of pattern matching to use matcher.matches() to check if the input matches the regexp before calling the group() method.→ <<cset 7c6dab1a38a1>>
-
reporter References
#93: Removes usage of matcher.group(...) when the string does not match, which causes an exception.→ <<cset 6f6bae4bd2b3>>
-
reporter References
#93: Adds the usage of the getType method for parameter types, which makes sure that the type exists.→ <<cset 06cc4ab9b3b8>>
- Log in to comment