fix: trim whitespace from string attributes on BaseModel#2504
Open
bpotmalnik wants to merge 1 commit into
Open
fix: trim whitespace from string attributes on BaseModel#2504bpotmalnik wants to merge 1 commit into
bpotmalnik wants to merge 1 commit into
Conversation
540ef03 to
bd156ce
Compare
Contributor
Author
|
I was considering if it is breaking change or not, but it would break things only if people would assert things agains hardcoded strings (which likelihood is pretty low) so I think it can got to v1. |
Laravel's TrimStrings middleware is intentionally skipped for Livewire requests (Livewire\Mechanisms\HandleRequests\HandleRequests calls TrimStrings::skipWhen). This means leading/trailing whitespace entered via Livewire forms (e.g. the admin panel) is never stripped before reaching the model, allowing values like " size " to be persisted. Override setAttribute() on BaseModel to trim all incoming string values before delegating to the parent. This covers every model in Lunar (handle, sku, slug, coupon, code, reference, postcode, etc.) Fixes lunarphp#1664
bd156ce to
84e543d
Compare
Contributor
|
I don’t think this is a suitable fix
|
Contributor
Author
|
@wychoong I hear you. I still think that reinstating default Laravel behavior would be handy for users (developers) using the package. As it is not indeed default filament behavior, but this package is kind of special case where lunar is in control of both core and admin panel itself (filament) which can drive handy behaviors. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Laravel's TrimStrings middleware is intentionally skipped for Livewire requests (Livewire\Mechanisms\HandleRequests\HandleRequests calls TrimStrings::skipWhen). This means leading/trailing whitespace entered via Livewire forms (e.g. the admin panel) is never stripped before reaching the model, allowing values like " size " to be persisted.
Override setAttribute() on BaseModel to trim all incoming string values before delegating to the parent. This covers every model in Lunar (handle, sku, slug, coupon, code, reference, postcode, etc.)
Fixes #1664