User tests: Successful: Unsuccessful:
When you save an article with spaces, before or after the title, the spaces are saved in the database.
Ordering the Articles by Titles which start with spaces, give confusing results.
This PR removes the spaces before and after the Article Title when saving the Article.
In the back-end under Content > Articles:
In the front-end:
In the back-end, if you add spaces before or after the Article Title, those are saved in the database
In the front-end, if you add spaces before or after the Article Title, those are saved in the database
In the back-end, the "Some titels start with a space or more spaces" is listed first because it starts with spaces.
However the back-end list does not show those spaces:
In the back-end, after save the spaces are removed before and after the Article Title
In the front-end, after save the spaces are removed before and after the Article Title
In the back-end the order is now correct:
Please select:
Documentation link for docs.joomla.org:
No documentation changes for docs.joomla.org needed
Pull Request link for manual.joomla.org:
No documentation changes for manual.joomla.org needed
Status | New | ⇒ | Pending |
Category | ⇒ | Administration com_content Front End |
I have tested this item ✅ successfully on 5100f56
tested successfully site/admin/api content creation
Slightly concerned that someone might have been using spaces as a way to trick the sort order on their site to force an article to the top of the list
Status | Pending | ⇒ | Ready to Commit |
Labels |
Added:
PR-5.3-dev
|
RTC
I am sorry to say, but the changes is incorrect.
Issues:
Side note: The spaces does not matter in HTML, so I do not think we should even worry about it.
You can do: <p> Foobar </p>
and it will be just Foobar
on the page.
I removing RTC, and would suggest to close the PR.
Anyway, thanks for the try :)
Status | Ready to Commit | ⇒ | Pending |
@Fedik The problem that is being solved is not preventing spaces being displayed. The problem that this PR addresses is that spaces before any other text are included in the sort order. Spaces at the end have no impact on anything.
Slightly concerned that someone might have been using spaces as a way to trick the sort order on their site to force an article to the top of the list
we should not alter user input
always agree with that
Agree with @Fedik.
I don't think we should disempower users.
I understand the intention, because in most cases a leading space before the title will be an oversight. Therefore, I could imagine that a warning is displayed when saving: “Your title starts with a space.”. But not auromatically change input.
I have tested this item ✅ successfully on 5100f56
Tested it and after the patch the spaces before or after are removed and the sorting of the titles is correct again
Status | Pending | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2025-06-04 18:21:27 |
Closed_By | ⇒ | HLeithner | |
Labels |
Added:
RMDQ
|
I have tested this item ✅ successfully on 5100f56
I have tested this successfully. Thanks Pe7er.
This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/45501.