Skip to content

Conversation

@devcircus
Copy link
Contributor

@devcircus devcircus commented Oct 19, 2017

Addresses #321
Also, if you look closely at #318, the failure was due to two whitespaces after "JSON".

Current

Currently, the way the subject is checked DoesNotContainUrlRule is that the subject is "exploded" into an array, then each element is checked via:

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

if the loop completes, with each element failing the 'url' check, then the custom rule passes.

Problem

The problem is that if there is more than one space between words in the subject, some elements of the exploded subject will just be an empty string, which in this case passes ['word' => 'url'] validation. This in turn makes the custom rule fail.

Goal

Honestly, I think you should consider adding some sanitization to your inputs, then we could avoid this fix. So if you don't want to pull this in, and address it closer to the beginning of the request, that's great as well.

Copy link
Member

@driesvints driesvints left a comment

Choose a reason for hiding this comment

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

Thanks for sending this in! Just two small changes needed and I'll merge this.

->see('Foo Tag')
->see('Thread successfully created!');
}

Copy link
Member

Choose a reason for hiding this comment

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

You can remove this test again. The bug is covered with the smaller test for the validation rule above.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

{
const STRING_WITH_URL = 'This is a string http://example.com with an url in it.';
const STRING_WITHOUT_URL = 'This is a string without an url in it.';
const STRING_WITH_A_REGRESSION = 'JSON not possible with MSSQL running on Windows platform?';
Copy link
Member

Choose a reason for hiding this comment

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

Can you remove this constant again? I forgot to remove it in a previous commit :')

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

@devcircus
Copy link
Contributor Author

I'll take care of the requested changes shortly. Thanks!

@driesvints driesvints merged commit 4ee1a95 into laravelio:master Oct 19, 2017
@driesvints
Copy link
Member

Thanks! Will come online in a bit.

@devcircus devcircus deleted the fix-extra-whitespace-in-subject-bug branch October 19, 2017 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants