-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Add html input validation in the form component #15315
Conversation
@eVoloshchak @tgolen One of you needs to copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
Hey! I see that you made changes to our Form component. Make sure to update the docs in FORMS.md accordingly. Cheers! |
Waiting on copy, but ready for an initial review. Been testing it pretty heavily |
Yeah that is a good catch @eVoloshchak . I'd say its a rare case in general. If someone putting anything resembling tags where a routing number is supposed to be, they should be notified that that act is not allowed. The "Please enter valid Routing Number" to me, is a "friendly" message for "friendly" users |
Copy updated. Ready for review |
src/components/Form.js
Outdated
const validationErrors = this.props.validate(values); | ||
|
||
// Validate the input for html tags. It should superseed any other error | ||
_.every(values, (inputValue, inputID) => { | ||
if (!inputValue || inputValue.search(/<(.|\n)*?>/g) === -1) { |
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.
The CONST.js
file has VALIDATE_CODE_REGEX_STRING
. Could you please move this regex to the same place and define it there?
src/components/Form.js
Outdated
return; | ||
} | ||
|
||
validationErrors[inputID] = this.props.translate('common.error.inputHasHtml'); |
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.
Let's rename this to common.error.invalidCharacter
so that it matches the text
Updated |
@eVoloshchak Looks like this just needs an approved review from you now. Are you able? |
Thanks! @marcaaron Could you add a review, please? |
Co-authored-by: Marc Glasser <marc.aaron.glasser@gmail.com>
Updated |
src/components/Form.js
Outdated
// Validate the input for html tags. It should supercede any other error | ||
_.each(values, (inputValue, inputID) => { | ||
// Return early if there is no value OR the value is not a string OR there are no HTML characters | ||
if (!inputValue || !_.isString(inputValue) || inputValue.search(CONST.VALIDATE_FOR_HTML_TAG_REGEX) === -1) |
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.
missing the opening curly brace
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.
Akward :blush
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
🚀 Deployed to staging by https://github.com/tgolen in version: 1.2.83-0 🚀
|
🚀 Deployed to staging by https://github.com/tgolen in version: 1.2.83-0 🚀
|
🚀 Deployed to production by https://github.com/roryabraham in version: 1.2.83-3 🚀
|
Details
WAF input rules filter out html/xml tags in most API parameters. Given that we rarely want users to submit html tags as inputs, we have decided to validate all inputs for html. And we will do so in the
Form
component.Here is what it would look like:
First/Last Name-
Workspage Settings -> General -
Fixed Issues
$ #14610
PROPOSAL: GH - Slack
Tests
Offline tests
QA Steps
Let's test that it picks up for html tags, but the focus here is to make sure we don't have regressions
test<b>
. Verify that there is an errortest<
and verify that you get an error saying you can only have characterstest
. Verify that error is gone.hello <b>
. Verify you get an errorhello
<b> </b>
as the workspace name. Verify that you see an error when you blur the field or submit the formKosuke<b>
. Verify that you get an error messagePR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)src/languages/*
files and using the translation methodWaiting for Copy
label for a copy review on the original GH to get the correct copy.STYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)/** comment above it */
this
properly so there are no scoping issues (i.e. foronClick={this.submit}
the methodthis.submit
should be bound tothis
in the constructor)this
are necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);
ifthis.submit
is never passed to a component event handler likeonClick
)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
Web
https://recordit.co/0eTSnGSP6r
Mobile Web - Chrome
https://recordit.co/cIOjb7gHc7
Mobile Web - Safari
https://recordit.co/0L0CmlQRJF
Desktop
https://recordit.co/rrvronUa7p
iOS
https://recordit.co/6mxyX6mqLe
Android
https://recordit.co/F8zbIrxmPn