Opened 13 years ago
Closed 10 years ago
#5093 closed enhancement (worksforme)
Leading whitespace in display names messes with alphabetical sort
| Reported by: | boonebgorges | Owned by: | |
|---|---|---|---|
| Priority: | lowest | Milestone: | |
| Component: | Core | Version: | |
| Severity: | minor | 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
@
10 years ago
- Milestone 2.8
- Resolution → worksforme
- Status new → 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_savecallbacks, 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
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
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.