Resolved Detection of items with brackets in name fails

Discussion in 'Client & Site Support' started by Aidden, Jan 19, 2015.

  1. Inventory.newQuery().names("Guam potion (unf)").results().first() returns null
    Inventory.newQuery().names("Guam potion \\(unf\\)").results().first() finds the correct item

    @Cloud
     
  2. Seems like the names(String...) is converting the Strings to Patterns but doesn't escape the brackets :/

    Edit: Which means this might be occurring in the other queries as well
     
  3. For the next release, does this check out to you?
    Code (Text):
    1.  
    2. public static Pattern getPatternForExactString(final String string) {
    3. String pattern = "^";
    4. for (char c : string.toCharArray()) {
    5. if (c == '(' || c == ')' || c == '^' || c == '$'|| c == '.' || c == '*' || c == '?' || c == '|'|| c == '[' || c == '{') {
    6. pattern += "\\";
    7. }
    8. pattern += c;
    9. }
    10. pattern += "$";
    11. return Pattern.compile(pattern);
    12. }
    13.  
     
  4. What about the closing braces and brackets?
     
  5. You could use IDs instead of names anyway since SpriteItem IDs dont change
     
  6. While that's true, it's could cause problems in other areas.
     
  7. Plus you'd have to gather all of the IDs, which would be a drag :p
     
  8. From my research, those only need to be escaped when the prior opening isn't escaped.
    Yeah, but I really don't recommend that.
     

Share This Page

Loading...