?
avatar PhilETaylor
PhilETaylor
28 May 2021

Steps to reproduce the issue

A good example of this is in #34233, specifically this comment #34233 (comment) where you can right click and modify the value of the selected item, and click save, and it is saved in the database.

you do that like this video, and then click save, and then inspect your db and you will see the faked value added to the db

Screen.Recording.2021-05-28.at.05.35.53.pm.mp4

Expected result

That any POSTed value is revalidated against the available options presented when the form was rendered before saving to the db.

Actual result

The unfiltered value is saved to the db

avatar PhilETaylor PhilETaylor - open - 28 May 2021
avatar joomla-cms-bot joomla-cms-bot - change - 28 May 2021
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - labeled - 28 May 2021
avatar PhilETaylor PhilETaylor - change - 28 May 2021
Title
[4][Security filelist field type doesnt validate the input
[4][Security] filelist field type doesnt validate the input
avatar PhilETaylor PhilETaylor - edited - 28 May 2021
avatar PhilETaylor PhilETaylor - change - 28 May 2021
The description was changed
avatar PhilETaylor PhilETaylor - edited - 28 May 2021
avatar PhilETaylor PhilETaylor - change - 28 May 2021
Title
[4][Security] filelist field type doesnt validate the input
[4][Security] filelist field type doesnt validate the input before saving
avatar PhilETaylor PhilETaylor - edited - 28 May 2021
avatar brianteeman
brianteeman - comment - 28 May 2021

I gave up trying to get a response to this. I think I have 3 open and 2 closed issues =- the last of which was closed "now that j4 was as broken as j3 "

avatar Fedik
Fedik - comment - 28 May 2021

The field does not validate anything if it not configured to.

where you can right click and modify the value of the selected item, and click save, and it is saved in the database.

For this we have a rule Joomla\CMS\Form\Rule\OptionsRule, to validate whether the value from the list.
That should be used when such validation needed.

https://github.com/joomla/joomla-cms/blob/3a5984d03366f707ef842ee48051af194f68848f/libraries/src/Form/Rule/OptionsRule.php

avatar PhilETaylor
PhilETaylor - comment - 28 May 2021

For this we have a rule Joomla\CMS\Form\Rule\OptionsRule

Oh sexy... pity its not actually used though :-)

avatar richard67
richard67 - comment - 29 May 2021

The OptionsRule only works for list fields but not for filelist fields as far as I remember (but I might be wrong).

But I'm currently working on new validation rules.

avatar Fedik
Fedik - comment - 29 May 2021

OptionsRule should work for all fields that provide $field->options property. (At least how it looks in the code).

Filelist field extend the list field, and so also should work.

avatar richard67
richard67 - comment - 29 May 2021

For the example mentioned here, we could also use the new "FilePathExistsRule" rule (i.e. validate="filePathExists") which will be added by my PR #34277 .

@PhilETaylor Would my PR #34277 close this issue here, or do you want to wait with that until it has been merged and the new rule is used at all places where it's necessary?

avatar richard67
richard67 - comment - 30 May 2021

Hmm, for filelist and folderlist fields, my new validation rules aren't really necessary because the files or folders have to exist for being added to the options.

But the OptionsRule would work.

So there are 2 ways to go:

  • Either add validate="options" to all fields of type "filelist" or "folderlist" in the XML, or
  • Let these fields use validate="options" by default if no other validation is specified.

The 2nd possibility would be a B/C break, I think.

avatar richard67
richard67 - comment - 30 May 2021

Closing as having a pull request. Please test #34284 . Thanks in advance.

avatar richard67 richard67 - change - 30 May 2021
Status New Closed
Closed_Date 0000-00-00 00:00:00 2021-05-30 11:18:23
Closed_By richard67
avatar richard67 richard67 - close - 30 May 2021

Add a Comment

Login with GitHub to post a comment