RMDQ PR-5.3-dev Pending

User tests: Successful: Unsuccessful:

avatar pe7er
pe7er
20 May 2025

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.

Summary of Changes

This PR removes the spaces before and after the Article Title when saving the Article.

Testing Instructions

In the back-end under Content > Articles:

  • create some Articles with Titles
  • add spaces before one of the Titles and save
  • click on the Order Title
  • notice that the ordering seems wrong (the Titles with spaces in front of them are listed first)

In the front-end:

  • edit an existing article
  • add spaces before and after one of the Titles and save
  • see that the spaces are saved in front and after the title

Actual result BEFORE applying this Pull Request

In the back-end, if you add spaces before or after the Article Title, those are saved in the database

article-title-before-pr

In the front-end, if you add spaces before or after the Article Title, those are saved in the database

front-end-article-before-pr

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:

before-pr

Expected result AFTER applying this Pull Request

In the back-end, after save the spaces are removed before and after the Article Title

article-title-after-pr

In the front-end, after save the spaces are removed before and after the Article Title

front-end-after-pr

In the back-end the order is now correct:

after-pr

Link to documentations

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

avatar pe7er pe7er - open - 20 May 2025
avatar pe7er pe7er - change - 20 May 2025
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 20 May 2025
Category Administration com_content Front End
avatar exlemor exlemor - test_item - 20 May 2025 - Tested successfully
avatar exlemor
exlemor - comment - 20 May 2025

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.

avatar brianteeman brianteeman - test_item - 21 May 2025 - Tested successfully
avatar brianteeman
brianteeman - comment - 21 May 2025

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


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/45501.

avatar QuyTon QuyTon - change - 21 May 2025
Status Pending Ready to Commit
Labels Added: PR-5.3-dev
avatar QuyTon
QuyTon - comment - 21 May 2025

RTC


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/45501.

avatar Fedik
Fedik - comment - 25 May 2025

I am sorry to say, but the changes is incorrect.

Issues:

  • we should not alter user input here, as we do not do it in other text fields.
  • the code allows to bypass security filtering, and allows for code injections

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 :)

avatar Fedik Fedik - change - 25 May 2025
Status Ready to Commit Pending
avatar brianteeman
brianteeman - comment - 25 May 2025

@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

avatar chmst
chmst - comment - 25 May 2025

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.

avatar webmasterab webmasterab - test_item - 25 May 2025 - Tested successfully
avatar webmasterab
webmasterab - comment - 25 May 2025

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


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/45501.

avatar HLeithner HLeithner - change - 4 Jun 2025
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2025-06-04 18:21:27
Closed_By HLeithner
Labels Added: RMDQ
avatar HLeithner HLeithner - close - 4 Jun 2025
avatar HLeithner
HLeithner - comment - 4 Jun 2025

Hi @pe7er

thanks for the PR but we discussed this now several times in maintainers channel and come to the following conclusion:

  1. Fedir mentioned in comment that this would prevent our default filter
  2. We shouldn't touch user input if not really needed.

So I'm closing this PR.

Add a Comment

Login with GitHub to post a comment