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

Controllers validate method returns converted keys #26651

Closed
nicoeg opened this issue Nov 28, 2018 · 1 comment
Closed

Controllers validate method returns converted keys #26651

nicoeg opened this issue Nov 28, 2018 · 1 comment
Labels

Comments

@nicoeg
Copy link
Contributor

nicoeg commented Nov 28, 2018

  • Laravel Version: 5.7
  • PHP Version: 7.*
  • Database Driver & Version: Not used

Description:

When having request input arrays which keys contains . it is converted to -> when using data returned from the validate method in a Controller.

Since #25128 the Illuminate\Foundation\Validation\ValidatesRequests::validate method returns the input data directly from the validator instead of fetching it from the request. This means that the str_replace done in Illuminate\Validation\Validator:parseData to convert . to -> is also returned.

I don't believe that this is expected behaviour.
Possible solution would be to convert back -> before returning but then existing input keys containing -> would also be affected.
Either the validate method could be changed back to fetch data from the request or the dot's should be replaced with something less likely of occurring?

Steps To Reproduce:

Basic controller:

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class TestController extends Controller
{
    public function index(Request $request) {
        $validated = $this->validate($request, ['*' => 'required']);
        return $validated;
    }
}

Route:

Route::get('/', 'TestController@index');

Go to the page with the following query string ?nested[config.conf]=gsdggdfg

@nicoeg nicoeg changed the title validate method returns converted keys Controllers validate method returns converted keys Nov 29, 2018
@driesvints driesvints added the bug label Dec 3, 2018
@driesvints
Copy link
Member

We don't support dot notation in keys anymore sorry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants