-
Notifications
You must be signed in to change notification settings - Fork 19
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
feat: updated the custom expiration model design and truly blocking #1209
Conversation
c25abd9
to
2f5433c
Compare
91b9efe
to
7b28c5b
Compare
5396302
to
47deed3
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1209 +/- ##
=======================================
Coverage 88.42% 88.43%
=======================================
Files 399 399
Lines 8502 8508 +6
Branches 2089 2096 +7
=======================================
+ Hits 7518 7524 +6
Misses 941 941
Partials 43 43 ☔ View full report in Codecov by Sentry. |
47deed3
to
334c43b
Compare
334c43b
to
2485230
Compare
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.
LGTM
const onClickHandler = () => { | ||
let url = customerAgreement?.urlForButtonInModal; | ||
|
||
if (url) { | ||
// Check if the URL starts with 'http://' or 'https://' | ||
if (!url.startsWith('http://') && !url.startsWith('https://')) { | ||
// Prepend 'https://' if the URL is missing the protocol | ||
url = `https://${url}`; | ||
} | ||
|
||
// Navigate to the full URL | ||
window.open(url, '_blank'); // Opening in a new tab | ||
} | ||
}; |
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.
[curious] I wonder if this sort of validation around url formatting should live in the backend so when consuming the urls in the frontend, we could assume the URL is properly formatted with a protocol. This would simplify this frontend implementation and its associated tests by keeping less business logic in the frontend.
For example, when configuring the URL in Django Admin, if it's missing a protocol, could alternatively consider:
- Raising a
ValidationError
in theclean
method to prevent saving, and informing the user a protocol is required. - Do the above transform when saving the record, so it saves in the DB properly formatted.
Definitely an edge case but as is, if the configured URL is missing the protocol and does not support https, I believe this implementation would result in the link not working properly as it assumes https
(which is a valid assumption).
</p> | ||
</StandardModal> | ||
{/* eslint-disable-next-line react/no-danger */} | ||
<div dangerouslySetInnerHTML={{ __html: customerAgreement?.expiredSubscriptionModalMessaging }} /> |
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.
Did we want to use DomPurify.sanitize
here (see a couple other places in this repo it's used). Ideally, we should be using it anytime using dangerouslySetInnerHTML
to as a security measure to prevent unsafe HTML (e.g., script injection, XSS attacks, etc.).
I know we use dangerouslySetInnerHTML
in a few other places without DomPurify.sanitize
but it would be awesome if we can ensure DomPurify.sanitize
was added in these other spots, too 😄
Description
JIRA -> ENT-9616, ENT-9618
For all changes
Only if submitting a visual change