-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Validator] Add filenameCharset
and filenameCountUnit
options to File
constraint
#58485
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
Conversation
IssamRaouf
commented
Oct 7, 2024
•
edited by OskarStark
Loading
edited by OskarStark
Q | A |
---|---|
Branch? | 7.3 |
Bug fix? | no |
New feature? | yes |
Deprecations? | no |
Issues | Fix #58482 |
License | MIT |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a testcase to avoid further regression
I'm 👎 here: the length in bytes is what matters. Eg a storage can have a 255-max string field counted in bytes, and this validator guards against longer filenames. Validating in code points makes it really hard to validate any predictable maxlength. Also, nothing tells this accepts only UTF-8 (it doesn't, bytes are bytes, no encoding expected here). |
Hello @nicolas-grekas For the context of the filenameMaxLength constraint option, from its name alone, it clearly suggests a validation on the string's length. let's take this example :
#[Assert\File( Result: I find this contradictory 😅. |
Hello @OskarStark ok, I'm waiting for the issue to be validated |
We could make this opt-in, eg with a countUnit and a charset option (names taken from the Length constraint) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, here are some minor last changes.
Please also rebase to target 7.3 since this is a new feature.
And move the changelog lines in the 7.3 section.
filenameCharset
and filenameCountUnit
options to File
constraint
0e90fc5
to
d5dbcb5
Compare
aa6e31b
to
5be38d9
Compare
5be38d9
to
c714aa5
Compare
$payload, | ||
$filenameCharset, | ||
$filenameCountUnit, | ||
$filenameCharsetMessage |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$filenameCharsetMessage | |
$filenameCharsetMessage, |
…`File` constraint
Thank you @IssamRaouf. |