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

Prevent freeform and shortcode blocks from converting HTML entities #51123

Merged
merged 2 commits into from
Jun 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/block-library/src/freeform/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"attributes": {
"content": {
"type": "string",
"source": "html"
"source": "raw"
}
},
"supports": {
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/shortcode/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"attributes": {
"text": {
"type": "string",
"source": "html"
"source": "raw"
}
},
"supports": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ describe( 'invalid blocks', () => {
expect( hasAlert ).toBe( false );
} );

it( 'should strip potentially malicious script tags', async () => {
it( 'should not trigger malicious script tags when using a shortcode block', async () => {
let hasAlert = false;

page.on( 'dialog', () => {
Expand All @@ -94,9 +94,6 @@ describe( 'invalid blocks', () => {

// Give the browser time to show the alert.
await page.evaluate( () => new Promise( window.requestIdleCallback ) );

expect( console ).toHaveWarned();
expect( console ).toHaveErrored();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The console logs were triggered because the block was considered invalid, it's now valid, I don't see why the block should be invalid here.

Copy link
Member

Choose a reason for hiding this comment

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

I think this looks good. Expectation below remains unchanged and that's what matters.

expect( hasAlert ).toBe( false );
} );
} );