Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
wants to merge 1 commit into from
Closed

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

wants to merge 1 commit into from

Conversation

obozdag
Copy link
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
@@ -112,6 +112,7 @@ rule and message array formats, as well as available rules:
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
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
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
Contributor

Choose a reason for hiding this comment

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

Copy link
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
Member

kenjis commented Nov 6, 2023

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

@kenjis
Copy link
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