Skip to:
Content

BuddyPress.org

Opened 14 years ago

Closed 13 years ago

#4779 closed defect (bug) (fixed)

messge compose autocompletefb.js splitting user name wrongly

Reported by: mort3n Owned by: boonebgorges
Priority: normal Milestone: 1.8
Component: Messages Version: 1.6.1
Severity: normal Keywords: has-patch needs-testing
Cc:

Description

In

/bp-messages/js/autocomplete/jquery.autocompletefb.js

the user should be removed by

removeUsername: function(o){
var newID = o.parentNode.id.split('-');
jQuery('#send-to-usernames').removeClass(newID[1]);

The id being split contains the string 'un-user_name'. The code works great when 'user_name' contains no '-'. However, with

user_name = 'john-doe'

the code tries to remove class

john

which fails.
Using a

-

seems to be valid in user names
http://codex.wordpress.org/Function_Reference/sanitize_user

A fix is

removeUsername: function(o){
var newID = o.parentNode.id.substr(3);
jQuery('#send-to-usernames').removeClass(newID);

Another fix is

removeUsername: function(o){
var newID = o.parentNode.id.substr((o.parentNode.id.indexof('-'));
jQuery('#send-to-usernames').removeClass(newID);

Change History (2)

#1 @boonebgorges
13 years ago

  • Keywords has-patch needs-testing added
  • Milestone Awaiting Review1.8

Good catch. Ideally I'd like to see us stop using jquery.autocompletefb.js and use something that comes with WP (or is at least not crummy); see #4580. However, this seems like a straightforward fix if we keep the fb version for a few more releases.

#2 @boonebgorges
13 years ago

  • Owner set to boonebgorges
  • Resolutionfixed
  • Status newclosed

In 6928:

Improve JS for removing items from message recipient autocomplete list

This changeset introduces a more reliable method for removing usernames from
the list of message recipients, which works properly with usernames that
contain hyphens.

Fixes #4779

Props mort3n

Note: See TracTickets for help on using tickets.