Jump to content

Empty substring match in MAX_limitationsMatchArrayValue


Kai (DC)

Recommended Posts

Maybe I'm misunderstanding this but

function MAX_limitationsMatchArrayValue($value, $limitation, $op)
{
    if ($op == '==') {
        return strcasecmp($limitation, $value) == 0;
    } else if ($op == '=~') {
        if ($value == '') {
            return true;
        }
 

in lib/max/Delivery/limitations.delivery.php means that an empty string matches any substring match which seems wrong to me.

Because "" does not really substring match "a,b,c" now does it? Or am I missing the forest for the trees?

Link to comment
Share on other sites

Thanks for your reply. 🙂

We wrote a plugin that allows to match banners by our users' professions. This uses a "contains" ("=~") match (so it's looking for profession 1 in the list "1,2,3,4").

In some rare (and hard to reproduce) cases  a user would get banners for the wrong profession during a longer session. I tracked this down to profession info dropping from the session (that issue is on our end and I hopefully fixed that) in which case an empty string would be fed into the match. And since that returns true always (as per code above), suddenly banners with totally different profession groups were matching.

We don't have the issue for users who aren't logged in because in that case the plugin doesn't even try to match, but empty data for logged-in users cause the issue.

(I didn't file this as bug report because the issue can be fixed on our end but I wanted to understand why the code above does what it does.)

Edited by Kai (DC)
Forgot a paragraph
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...