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

trim whitespace on paste of code #758

Closed
jimdigriz opened this issue May 22, 2023 · 1 comment
Closed

trim whitespace on paste of code #758

jimdigriz opened this issue May 22, 2023 · 1 comment

Comments

@jimdigriz
Copy link
Contributor

jimdigriz commented May 22, 2023

Could you add a onpaste to tmpl/confirm_email.mustache to handle lesser {web,e}mail clients that seem to place sometimes considerable whitespace before the confirmation code?

Though you do remove all whitespace in src/bridges/email.rs:confirmation I am seeing the problem before we get to the endpoint due to the text input field having a limit of 20 and it submits a truncated confirmation instead.

"Why does this happen, surely 20 is enough?", you may ask, and it is true and it is a good question...but it turns out software hates all people...

What I have observed:

  1. the code emailed to me is 123456 abcdef (12 characters + 1 space)
  2. I double click on the code to paste it in to the confirmation box
  3. what is actually pasted is N leading spaces, I see mostly 1 which works fine in the 20 character limit but I am able to regularly have it paste in 8 leading whitespace characters which results in the trailing f being truncated/ignored
    • you can see this yourself if you press the space bar eight times before pasting in the code
    • the HTML in the email template is just the paragraph element wrapping the code so it seemingly is not something I can fix there: image

Maybe we could include something like:

<script>
 document.querySelector("input[name='code']").addEventListener("paste", function(e) {
  e.preventDefault();
  this.value = e.clipboardData.getData("text/plain").trim()
 });
</script>

The reason I am proposing the onpaste hook is:

  1. users may post trim the whitespace manually after seeing it pasted incorrectly but they are unlikely to notice a single character being trimmed off
  2. the user can still pound the enter key blindly :)
  3. I suspect we do not want to avoid the problem by just bumping the limit to something higher than 20, though this could work too? Maybe do both?
@stephank
Copy link
Member

Fixed in #781

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants