-
Notifications
You must be signed in to change notification settings - Fork 219
Conversation
The release ZIP for this PR is accessible via:
|
Size Change: +41.1 kB (+5%) 🔍 Total Size: 934 kB
ℹ️ View Unchanged
|
9de1905
to
6c71ebe
Compare
Hey @hsingyuc could you check the first step of your testing instructions - looks like there's some shorthand there that didn't parse correctly and I want to be sure we're getting the right instructions. Thanks! |
@opr Thank you for pointing that out! I've updated the instructions. |
Hey, I don't see the updated URL, could you let me know what PR you're referring to in step 1? Thanks! |
@opr I think it's working now, can you try again? Thank you! |
9fff5da
to
01b4a0f
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.
@@ -230,6 +230,7 @@ | |||
"config": "3.3.7", | |||
"dataloader": "2.1.0", | |||
"dinero.js": "1.9.1", | |||
"dompurify": "^2.4.0", |
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.
Looks like dompurify
already exists in the node_modules
directory - we have it from @woocommerce/data
. I don't think it's a problem to add it here.
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.
It is not redundant if it becomes a dependency for this project, and then it should definitely be added here. Removing @woocommerce/data or it stopping being a dependency for it won't bubble up into problems here
We could make use also of |
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.
@hsingyuc I just added a comment regarding the use of sanitize()
as I'm uncertain if the current implementation will work as expected.
const ALLOWED_TAGS = [ 'a', 'b', 'em', 'i', 'strong', 'p', 'br' ]; | ||
const ALLOWED_ATTR = [ 'target', 'href', 'rel', 'name', 'download' ]; | ||
|
||
const sanitizeHTML = ( html ) => { | ||
return { | ||
__html: sanitize( html, { ALLOWED_TAGS, ALLOWED_ATTR } ), | ||
}; | ||
}; |
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.
@hsingyuc While working on #7147, I was reusing this part. When looking at ALLOWED_TAGS
and ALLOWED_ATTR
, I noticed that they're not working as expected. https://github.com/cure53/DOMPurify#can-i-configure-dompurify shows the following example:
// allow only <b> and <q> with style attributes
var clean = DOMPurify.sanitize(dirty, {ALLOWED_TAGS: ['b', 'q'], ALLOWED_ATTR: ['style']});
Looking at the implementation above, I'd say that the current implementation would lead to this function call:
const sanitizeHTML = ( html ) => {
return {
__html: sanitize( html, {
[ 'a', 'b', 'em', 'i', 'strong', 'p', 'br' ],
[ 'target', 'href', 'rel', 'name', 'download' ]
} ),
};
};
I believe the function should be called like this instead:
const sanitizeHTML = ( html ) => {
return {
__html: sanitize( html, {
ALLOWED_TAGS: [ 'a', 'b', 'em', 'i', 'strong', 'p', 'br' ],
ALLOWED_ATTR: [ 'target', 'href', 'rel', 'name', 'download' ]
} ),
};
};
If that assumption is correct, I suggest the following change:
const ALLOWED_TAGS = [ 'a', 'b', 'em', 'i', 'strong', 'p', 'br' ]; | |
const ALLOWED_ATTR = [ 'target', 'href', 'rel', 'name', 'download' ]; | |
const sanitizeHTML = ( html ) => { | |
return { | |
__html: sanitize( html, { ALLOWED_TAGS, ALLOWED_ATTR } ), | |
}; | |
}; | |
const tags = [ 'a', 'b', 'em', 'i', 'strong', 'p', 'br' ]; | |
const attr = [ 'target', 'href', 'rel', 'name', 'download' ]; | |
const sanitizeHTML = ( html ) => { | |
return { | |
__html: sanitize( html, { ALLOWED_TAGS: tags, ALLOWED_ATTR: attr } ), | |
}; | |
}; |
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.
@nielslange, in ES6, it converts to below. If converted to the way you wrote, I believe we will get an error.
{
ALLOWED_TAGS: [ 'a', 'b', 'em', 'i', 'strong', 'p', 'br' ]
}
Merged this despite false positive of CI jobs failing. The main culprit was the linter not finding a report file:
This is unlikely to be due to this PR, although in retrospective it might be related to the change in |
Sanitizing the merchant store link in the error message added in WooPay when in some cases the customer could run into an issue where we need to tell them an error occurred and they have to go back to the merchant store and re-initialize WooPay to fix it. Because previously we were only expecting strings, the text was not sanitized.
Sanitizing the merchant store link in the error message added in WooPay when in some cases the customer could run into an issue where we need to tell them an error occurred and they have to go back to the merchant store and re-initialize WooPay to fix it. Because previously we were only expecting strings, the text was not sanitized.
Sanitizing the merchant store link in the error message added in WooPay when in some cases the customer could run into an issue where we need to tell them an error occurred and they have to go back to the merchant store and re-initialize WooPay to fix it. Because previously we were only expecting strings, the text was not sanitized.
This PR is sanitizing the merchant store link in the error message added in this PR. Because in some (rare) cases the customer could run into an issue where we need to tell them an error occurred and they have to go back to the merchant store and reinitialize WooPay to fix the issue. In these cases, it'd be great to include a link back to the merchant store.
Fixes 1130-gh-Automattic/woopay
Related PR 1287-gh-Automattic/woopay
Accessibility
prefers-reduced-motion
Other Checks
Screenshots
Testing
In src/Checkout/PaymentsHandler.php, comment or remove the if around the exception:
Automated Tests
Changes in this PR are covered by Automated Tests.
Do not include in the Testing Notes
WooCommerce Visibility
Performance Impact
Changelog
WooPay: fixed a compatibility issue with some error messages shown by WooPay.