Skip to content

docs: Use validateData() to validate POST data only#8157

Closed
obozdag wants to merge 1 commit intocodeigniter4:developfrom
obozdag:patch-2
Closed

docs: Use validateData() to validate POST data only#8157
obozdag wants to merge 1 commit intocodeigniter4:developfrom
obozdag:patch-2

Conversation

@obozdag
Copy link
Copy Markdown
Contributor

@obozdag obozdag commented Nov 6, 2023

Instead of withRequest(), use validateData() to validate POST data only. withRequest() uses $request->getVar() which returns $_GET, $_POST and $_COOKIE data in that order. Newer values override older values. Post values will be overriden by the cookies if they have the same name.

Description
Explain what you have changed, and why.

Checklist:

  • Securely signed commits
  • Component(s) with PHPDoc blocks, only if necessary or adds value
  • Unit testing, with >80% coverage
  • User guide updated
  • Conforms to style guide

Instead of withRequest(), use validateData() to validate POST data only. withRequest() uses $request->getVar() which returns $_GET, $_POST and $_COOKIE data in that order. Newer values override older values. Post values will be overriden by the cookies if they have the same name.
@kenjis kenjis added the documentation Pull requests for documentation only label Nov 6, 2023
@kenjis kenjis changed the title Use validateData() to validate POST data only docs: Use validateData() to validate POST data only Nov 6, 2023
or :ref:`$request->getRawInput() <incomingrequest-retrieving-raw-data>`
or :ref:`$request->getVar() <incomingrequest-getting-data>`, and an attacker
could change what data is validated.
Instead of withRequest(), use validateData() to validate POST data only. withRequest() uses $request->getVar() which returns $_GET, $_POST and $_COOKIE data in that order. Newer values override older values. Post values will be overriden by the cookies if they have the same name.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This warning will be too long.
Why don't you add another warning about this addition, and move it to the top of the section?
Personally $this->validate() is not recommended.

Suggested change
Instead of withRequest(), use validateData() to validate POST data only. withRequest() uses $request->getVar() which returns $_GET, $_POST and $_COOKIE data in that order. Newer values override older values. Post values will be overriden by the cookies if they have the same name.
Instead of ``validate()``, use ``validateData()`` to validate POST data only.
``withRequest()`` uses ``$request->getVar()`` which returns ``$_GET``, ``$_POST``
or ``$_COOKIE`` data in that order (depending on php.ini
`request-order <https://www.php.net/manual/en/ini.core.php#ini.request-order>`_).
Newer values override older values. POST values may be overridden by the
cookies if they have the same name.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the edit. That is what I was trying to explain. But unfortunately I don't know this markup language used here. I would appreciate if you could do it, please.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I sent #8169

@kenjis kenjis mentioned this pull request Nov 6, 2023
3 tasks
@kenjis
Copy link
Copy Markdown
Member

kenjis commented Nov 6, 2023

@obozdag I sent another PR to add another warnings in validation and incommingrequest: #8160

@kenjis
Copy link
Copy Markdown
Member

kenjis commented Nov 13, 2023

Closed by #8169

@kenjis kenjis closed this Nov 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Pull requests for documentation only

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants