Skip to content

Multiple spaces in thread subject fails 'url' validation #321

@devcircus

Description

@devcircus

After noticing #318, I started looking closer and this is what I found.

Issue

If, in your 'subject', you include multiple spaces between words, the 'DoesNotContainUrl' validation error will be triggered. This is because the following code successfully passes validation:

// from line 24 in DoesNotContainUrlRule.php

$validator->make(['word' => ''], ['word' => 'url'])->passes();

// returns true (which, in turn, causes false to be returned from the rule)

When we explode the subject and pass each element to the above validator, any elements that are an empty string will allow the validation to pass. Therefore the custom rule will fail.

Possible solutions

EDITED

  1. Add 'required' to the inner loop that validates each part of the string as a url. This way, if an empty string is checked, it will pass; allowing the custom rule to fail.
  2. Remove the extra spaces prior to the inner validation loop.
  3. Add sanitization to inputs, either at the middleware or form-request level.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions