LuckPerms

LuckPerms

41.4k Downloads

[API] Filtering/matching of MetaNodes by key isn't case insensitive

emilyy-dev opened this issue ยท 3 comments

commented

Description

Attempting to match meta nodes by meta key with NodeMatcher.metaKey(String)/NodeMatcher.metaKey(MetaNode) on meta nodes whose meta key isn't 100% lowercase yields false results.

Reproduction steps

Sample snippet

final String META_KEY = "SomeMetaNodeKey";
final MetaNode META_NODE = MetaNode.builder(META_KEY, "10").build();

// ...

final User user = this.userManager.getUser(player.getUniqueId());
if (user == null) {
  throw new RuntimeException();
}

final boolean b1 = user.getNodes(NodeType.META).stream().map(MetaNode::getMetaKey)
                       .anyMatch(META_KEY::equalsIgnoreCase);
player.sendMessage("anyMatch(META_KEY::equalsIgnoreCase) = " + b1);

final boolean b2 = user.getNodes(NodeType.META).stream()
                       .anyMatch(NodeMatcher.metaKey(META_KEY));
player.sendMessage("anyMatch(NodeMatcher.metaKey(META_KEY)) = " + b2);

final boolean b3 = user.getNodes(NodeType.META).stream()
                       .anyMatch(NodeMatcher.metaKey(META_NODE));
player.sendMessage("anyMatch(NodeMatcher.metaKey(META_NODE)) = " + b3);

Results

Expected behaviour

All three comparison should return true. Whether meta nodes key matching should be case sensitive or not is in my opinion a different question but this is undoubtedly unexpected behavior.

Environment details

  • Server type/version: Paper running version 1.16.4 build 320
  • LuckPerms version: v5.2.49

Any other relevant details

JavaDoc for those NodeMatcher methods indicate that "The String.equalsIgnoreCase(String) method is used to test key equality." which erm... doesn't look like it.

commented

Could you confirm whether the above commit fixes this issue?

commented

Yep, seems like that did it ๐Ÿ˜„

image

Kind of a separate issue / kind of not (since it's not API but it is due to the case sensitivity), but the lp search command seems to be suffering from a bit of the same of a problem.

image

commented

Seems like the /lp search issue is related to H2's case sensitivity. I wasn't aware until now, but it seems like H2 is not case insensitive like MySQL is.

I've been able to fix this for LIKE (what LP calls "similar") lookups - but not equals. I don't think it's a huge deal though.. Going to close for now since the original issue is sorted. :)