Only pass strings with a valid number to Str.fromUSDToNumber#25734
Conversation
Str.fromUSDToNumber now crashes if you pass a boolean true|false or strings that are not valid numbers
|
@narefyev91 Please 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] |
| filterInput(amount) { | ||
| let value = amount ? amount.toString().trim() : ''; | ||
| if (value === '' || !Math.abs(Str.fromUSDToNumber(value)) || _.isNaN(Number(value))) { | ||
| if (value === '' || _.isNaN(Number(value)) || !Math.abs(Str.fromUSDToNumber(value))) { |
There was a problem hiding this comment.
Change the order so we don't even try calling Str.fromUSDToNumber with something that is not a number
|
|
||
| _.each(values, (value, key) => { | ||
| const filteredValue = this.filterInput(value); | ||
| const filteredValue = typeof value === 'string' ? this.filterInput(value) : value; |
There was a problem hiding this comment.
filterInput is supposed to work only with string parameters, this avoid passing unexpected values.
Reviewer Checklist
Screenshots/VideosWebMobile Web - ChromeMobile Web - SafariDesktopiOSAndroid |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
Only pass strings with a valid number to Str.fromUSDToNumber (cherry picked from commit 2866504)
|
🚀 Deployed to staging by https://github.com/aldo-expensify in version: 1.3.56-17 🚀
|
|
🚀 Deployed to production by https://github.com/roryabraham in version: 1.3.56-24 🚀
|
|
🚀 Deployed to staging by https://github.com/aldo-expensify in version: 1.3.58-0 🚀
|
|
🚀 Deployed to production by https://github.com/luacmartins in version: 1.3.58-5 🚀
|
Details
Str.fromUSDToNumbernow crashes if you pass a boolean true|false or strings that are not valid numbersMore details on the crash: #25705 (comment)
Fixed Issues
$ #25705
PROPOSAL:
Tests
Offline tests
QA Steps
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)myBool && <MyComponent />.src/languages/*files and using the translation methodWaiting for Copylabel for a copy review on the original GH to get the correct copy.STYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)/** comment above it */thisproperly so there are no scoping issues (i.e. foronClick={this.submit}the methodthis.submitshould be bound tothisin the constructor)thisare necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);ifthis.submitis never passed to a component event handler likeonClick)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG))Avataris modified, I verified thatAvataris working as expected in all cases)ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Web
Screen.Recording.2023-08-22.at.4.34.07.PM.mov
Mobile Web - Chrome
Mobile Web - Safari
Desktop
iOS
Android