Skip to content
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

fix: change length of email field #4118

Merged
merged 5 commits into from
Nov 22, 2024

Conversation

DavideIadeluca
Copy link
Contributor

2.x pendent to #4117

Fixes #0000
It appears as if the email validator allows 254 chars for the entire email, while the DB field only allows 150. This results in email addresses simply being truncated without any error message when creating users with longer email addresses.

Changes proposed in this pull request:
Increase length of email field to 254 chars to match the validator

Reviewers should focus on:
See https://www.rfc-editor.org/errata/eid1690

Screenshot

Necessity

  • Has the problem that is being solved here been clearly explained?
  • If applicable, have various options for solving this problem been considered?
  • For core PRs, does this need to be in core, or could it be in an extension?
  • Are we willing to maintain this for years / potentially forever?

Confirmed

  • Frontend changes: tested on a local Flarum installation.
  • Backend changes: tests are green (run composer test).
  • Core developer confirmed locally this works as intended.
  • Tests have been added, or are not appropriate here.

Required changes:

  • Related documentation PR: (Remove if irrelevant)

Copy link
Member

@SychO9 SychO9 left a comment

Choose a reason for hiding this comment

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

Looks like the reason it's failing is that the email tokens table also needs its email column to be increased in length, could you please add a migration for that as well? MySQL probably just truncates without failing whereas PgSQL is more strict so it fails. Which is likely why tests succeeded in 1.x

but that also means email tokens (needed for account confirmations) won't work properly for emails longer than 150 in 1.x, it looks like confirming the account in 1.x will trigger the app to change the email back to the truncated value, assuming that's what's happening (https://github.com/flarum/framework/blob/1.x/framework/core/src/User/Command/ConfirmEmailHandler.php#L45)

@SychO9 SychO9 added this to the 2.0 milestone Nov 22, 2024
@DavideIadeluca
Copy link
Contributor Author

Yep, seems like it was exactly what you mentioned – Thanks for looking into this. Will PR 1.x with the same fix

@DavideIadeluca DavideIadeluca marked this pull request as ready for review November 22, 2024 09:49
@DavideIadeluca DavideIadeluca requested a review from a team as a code owner November 22, 2024 09:49
Copy link
Member

@SychO9 SychO9 left a comment

Choose a reason for hiding this comment

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

Thanks!

@SychO9 SychO9 merged commit 49064f6 into flarum:2.x Nov 22, 2024
21 checks passed
@DavideIadeluca DavideIadeluca deleted the di/change-email-length branch November 22, 2024 10:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants