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

Use WTForm for source interface submission form #5226

Merged
merged 1 commit into from
May 4, 2020

Conversation

rmol
Copy link
Contributor

@rmol rmol commented May 4, 2020

Status

Ready for review

Description of Changes

Adds SubmissionForm to securedrop/source_app/forms.py, supporting validation of the source submission form. Rework lookup.html to use it: some presentation (the placeholder) had to be moved to the form, because the translated message couldn't be interpolated into the SubmissionForm construction in the template.

Note that this change does not add the maxlength attribute to the message textarea, as Firefox doesn't limit the text length accurately when it includes newlines and can submit a message longer than the validator limit.

Testing

  • Check out the source-submission-wtform branch.
  • Run make dev
  • Navigate to the source submission page.
  • Copy more than 100000 bytes of text, paste it into the message textarea, submit, and confirm that you get an error saying Message text too long. Large blocks of text must be uploaded as a file, not copied and pasted.
  • Submit a short message and confirm that there is no validation error.
  • Confirm that you can still upload a file larger than 100000 bytes.
  • Navigate to the journalist interface, under the instance config admin page, and disable uploads.
  • Retry the large paste test, and confirm that the message is simply Message text too long.

Checklist

If you made changes to the server application code:

  • Linting (make lint) and tests (make test) pass in the development container

If you made non-trivial code changes:

  • I have written a test plan and validated it for this PR

@rmol rmol force-pushed the source-submission-wtform branch from cf315b7 to 4a370f4 Compare May 4, 2020 16:29
@emkll emkll added this to the 1.3.0 milestone May 4, 2020
Adds SubmissionForm to securedrop/source_app/forms.py, supporting
validation of the source submission form. Rework lookup.html to use
it: some presentation (the placeholder) had to be moved to the form,
because the translated message couldn't be interpolated into the
SubmissionForm construction in the template.

Note that this change does *not* add the maxlength attribute to the
message textarea, as Firefox doesn't limit the text length accurately
when it includes newlines and can submit a message longer than the
validator limit.
@rmol rmol force-pushed the source-submission-wtform branch from 4a370f4 to 412103d Compare May 4, 2020 18:10
Copy link
Contributor

@zenmonkeykstop zenmonkeykstop left a comment

Choose a reason for hiding this comment

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

As per test plan:

  • Check out the source-submission-wtform branch.
  • Run make dev
  • Navigate to the source submission page.
  • Copy more than 100000 bytes of text, paste it into the message textarea, submit, and confirm that you get an error saying Message text too long. Large blocks of text must be uploaded as a file, not copied and pasted.
  • Submit a short message and confirm that there is no validation error.
  • Confirm that you can still upload a file larger than 100000 bytes.
  • Navigate to the journalist interface, under the instance config admin page, and disable uploads.
  • Retry the large paste test, and confirm that the message is simply Message text too long.

Diff review also LGTM!

@zenmonkeykstop zenmonkeykstop merged commit ec2220c into develop May 4, 2020
@zenmonkeykstop zenmonkeykstop deleted the source-submission-wtform branch May 4, 2020 20:55
@emkll emkll mentioned this pull request May 6, 2020
22 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants