thekrakken / java-grok

Simple API that allows you to easily parse logs and other files
http://grok.nflabs.com/
Other
358 stars 152 forks source link

Mach class bug #41

Closed agadek closed 1 year ago

agadek commented 8 years ago

I'd like to porpose simple code fix:

/**

remove from the string the quote and double quote. *
@param value string to pure: "my/text"

@return unquoted string: my/text
*/
private String cleanString(String value) {
if (value == null) {
return null;
}
if (value.isEmpty()) {
return value;
}
char[] tmp = value.toCharArray();
if ((tmp[0] == '"' && tmp[value.length() - 1] == '"')
|| (tmp[0] == '\'' && tmp[value.length() - 1] == '\'')) {

if (value.length() != 1) {
  value = value.substring(1, value.length() - 1);
} else {
  value = "";
}

}
return value;
}

Now, method throws string out of boundary exception in case of string with single quote sinse like ' or "

retoo commented 7 years ago

This can be closed, this is not the case with the current version of java-grok. This probably was fixed by 8a8234af500876d3ed3eede4c63f587f6f9e2b14 from @hayatbehlim .