Opened 12 years ago
Closed 8 years ago
#5093 closed enhancement (worksforme)
Leading whitespace in display names messes with alphabetical sort
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | lowest | |
Severity: | minor | Version: | |
Component: | Core | Keywords: | needs-testing needs-patch |
Cc: | vivek@… |
Description
If a username is entered as " Boone" rather than "Boone", it'll show up first in the list when doing an alphabetical sort. In my experience, a name is typically entered with leading whitespace by accident. But it could also be used as a sort of hack to get your profile to the top of the list. We might consider trimming this whitespace, either on the way in (at the time of profile save), or at the time of query:
ORDER BY LTRIM(u.value)
Are there legit reasons for wanting leading whitespace? Would the latter query cause performance issues at scale? Needs testing.
Change History (4)
#4
@
8 years ago
- Milestone 2.8 deleted
- Resolution set to worksforme
- Status changed from new to closed
On further testing, it appears that field data is, in fact, stripped on save. I can't see at a glance when this change took place, but the stack trace is:
xprofile_set_field_data()
causesBP_XProfile_ProfileData::save()
to be runsave()
runsxprofile_data_value_before_save
callbacks, including https://buddypress.trac.wordpress.org/browser/trunk/src/bp-xprofile/bp-xprofile-filters.php?marks=55#L51xprofile_sanitize_data_value_before_save()
runs through the 'xprofile_filtered_data_value_before_save' filter https://buddypress.trac.wordpress.org/browser/trunk/src/bp-xprofile/bp-xprofile-filters.php?marks=188#L153- which is trimmed https://buddypress.trac.wordpress.org/browser/trunk/src/bp-xprofile/bp-xprofile-filters.php?marks=56#L51
While I can imagine special characters such as the exclamation/bang/! as the genuine leading letter in a name, I can't think of any reasons why a leading space would be needed.
We should trim it on profile save.