Closed (fixed)
Project:
Drupal core
Version:
11.x-dev
Component:
mail system
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
13 Nov 2023 at 14:30 UTC
Updated:
19 Jul 2024 at 08:14 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
znerol commentedPostponed on #3399645: Use structured DSN instead of URI in system.mail mailer_dsn.
Comment #3
znerol commentedComment #4
znerol commentedAccording to RFC 3986 Appendix A, syntax validation of the
schemekey seems possible with a regex.ABNF for scheme is:
Translated to a regex:
/[a-z][a-z0-9+\-\.]*/iThe
hostpart seems tricky just with a regex. It may be an IP address literal or alternatively it may be a string of alphanumeric plus quite some punctuation characters. The host part may even contain percent escaped characters. Also the IP address literals are allowed in numerous different formats.I think that for the
hostfield it would be best to implement a custom validator.There is no restriction for the
userandpasswordfields. The parse_url and urldecode (as used by DSN::fromString()) happily accept various control characters (including "%00"). Remote systems probably wouldn't accept user names and passwords with newlines and tabs, but from a spec point of view, such strings are acceptable.Same for the option values. They actually can contain anything.
Comment #6
znerol commentedThere is also RFC 6874 specifying the correct syntax for IPv6 zone ids.
Comment #7
znerol commentedIt looks like
parse_url()accepts a wide range of characters in the host part which are clearly not allowed according to the RFC. E.g., non-ascii letters, the ampersand, colons outside of brackets, etc. However, it replaces control characters with an underscore (including newlines).Hence, let's reuse the regex from the label data type for the host field.
Comment #8
smustgrave commentedFor the new schema type could we get a change record.
Comment #9
znerol commentedCR added.
Comment #10
smustgrave commentedThanks! The config move to it's own type seems fine to me.
Comment #11
quietone commentedThis is more than just a config move, it is also adding constraints. And as such I think those new constraints need to be accompanied with tests.
Comment #12
znerol commentedAdded tests.
Comment #13
znerol commentedComment #14
znerol commentedSwitched parent to #2952037: [meta] Add constraints to all simple configuration
Comment #15
smustgrave commentedLeft a comment on the MR.
Don't think we will need an upgrade path as the types don't seem to be changing but not 100% on that.
Comment #16
znerol commentedI added the
FullyValidatableconstraint to thesystem.mailconfig. But honestly, I'm not quite sure on which level this should be added (config level or core datatype level, or even/additionally inmailer_dsn.options.x).Comment #17
znerol commentedGist of a slack conversation with @penyaskito:
Turned out that the
Hostnamevalidator isn't quite enough, since thehostparameter also should accept IP addresses. I've investigated whether it would be possible to implement this using theAtLeastOneOfand a combination ofHostnameandIp. But that doesn't allow for IPv6 literals (enclosed in brackets).I guess it would be best to just introduce an
UriHostconstraint, which implements RFC 3986 section 3.2.2.Comment #18
znerol commentedAdded tests for the new
UriHostconstraint. Note thatfilter_var($value, \FILTER_VALIDATE_DOMAIN, \FILTER_FLAG_HOSTNAME)accepts every valid IPv4, thus removed the explicit call tofilter_var($value, \FILTER_VALIDATE_IP, \FILTER_FLAG_IPV4).Comment #19
borisson_I love the new test coverage here, this is really good. I had one remark on the type definition, but I'm not sure if that would be better.
Comment #20
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #21
znerol commentedComment #22
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #23
znerol commentedNow that #3449214: A revert has cause cspell to fail due to the word yarhar is fixed, this shouldn't fail the needs review queue bot anymore.
Comment #24
znerol commentedComment #25
smustgrave commentedRan test-only feature https://git.drupalcode.org/issue/drupal-3401255/-/jobs/1638536 which shows coverage.
Appears all feedback has been addressed
I reviewed the CR and detail is on point.
Believe this one to be good to go.
Comment #29
znerol commentedComment #30
znerol commentedCopied credits over from #3440975: Add validation constraints to system.mail
Comment #31
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #32
znerol commentedComment #34
smustgrave commentedSeems to just be a rebase so will restore.
Comment #35
alexpottI think if we make password and user are now nullable I think we should consider whether we allow blanks. And if we don;t allow blanks then we might need a update path.
Comment #36
znerol commentedI feel that the proposed changes do have some potential for breakage. Keep in mind that transports are pluggable. And there are some transports in the wild which are using HTTPS to talk directly to an API instead of SMTP.
I did encounter API keys in the past, which leveraged basic auth in weird ways. In one example the whole API key went into the user part, and the password part was supposed to be left blank. See this random bug report on python requests which is referring to that method.
For that reason, I'd prefer if we wouldn't add the
NotBlankconstraints, unless there are strong reasons for it.Comment #37
alexpottTurns out my concerns are invalid - thanks @znerol - I think the rtbc in #34 stands.
Comment #39
alexpottCommitted 87bf1ee and pushed to 11.x. Thanks!
Comment #40
wim leersVery nice — I hadn't seen this while working on #3440975: Add validation constraints to system.mail, but #17 is a good reason to not reuse Symfony's existing
Hostnamevalidation constraint 👍