Skip to:
Content
Pages
Categories
Search
Top
Bottom

Message sent to removed autocompleted recipient


  • mort3n
    Participant

    @mort3n

    Hi,

    I have autocomplete on searching all members in the message component via wp-config
    `define( β€˜BP_MESSAGES_AUTOCOMPLETE_ALL’, true );`

    When composing a new message I can reproduce this error :
    1) type first part of name. A list of users is shown.
    2) Choose user A.
    3) type first part of another name. A list of users is shown.
    4) Choose user B.
    5) Remove one of the recipients (A or B). Only one recipient is listed as should be the case.
    6) Compose message and send.

    Both user A and B recieve the message.

    I have tried to take a look at the code and have found the following :

    In `bp-messages/bp-messages-screens.php`

    The recipients are stored in these two variables
    `$autocomplete_recipients = explode( ‘,’, $_POST[‘send-to-input’] );
    $typed_recipients = explode( ‘ ‘, $_POST[‘send_to_usernames’] );
    `

    In `/bp-messages/js/autocomplete/jquery.autocompletefb.js` the user should be removed by
    `
    40 removeUsername: function(o){
    41 var newID = o.parentNode.id.split(‘-‘);
    42 jQuery(‘#send-to-usernames’).removeClass(newID[1]);
    43 }
    `
    but it isn’t.

    Perhaps, this is caused by `split()` being deprecated as of PHP 5.3,
    http://dk1.php.net/manual/en/function.split.php
    but I don’t know.

    Any ideas much appreciated!

    Cheers
    Mort3n

Viewing 1 replies (of 1 total)

  • mort3n
    Participant

    @mort3n

    Update

    First of all, my comment above about `split()` is obviously wrong since this is JS `split()`, not PHP πŸ™‚

    Anyway, having looked a bit deeper it is exactly the (JS πŸ˜‰ ) `split()` is the culprit.

    The id being `split()` contains the string

    un-username

    The code will split this on `-` and return the second part. This works great, as long as

    username

    has no `-`.

    The site where I have seen this error uses user names of the form `john-doe`. The code therefore splits the `id` into three parts `un`, `john`, `doe` and returns the second part, `john`. Then it tries to remove class `john` which fails since the class to be removed is `john-doe`.

    As far as I can see `-` is allowed in user names https://codex.wordpress.org/Function_Reference/sanitize_user

    Any ideas for a workaround?

    Cheers
    Mort3n

Viewing 1 replies (of 1 total)
  • The topic ‘Message sent to removed autocompleted recipient’ is closed to new replies.
Skip to toolbar