Skip to content

Conversation

@iamdereky
Copy link
Contributor

Fixes #228060

Description: When using HTML escaped quotes for style attributes in an HTML file, the CSS region no longer throws an error. While the escaped quote is still displayed in the original document, the extension now embeds the escaped quote as a quotation mark with additional spaces to maintain the embedded document's one-to-one requirement with the original document. Changes were also made to ensure that hovering over the CSS region will highlight the entire region (including the HTML escaped quotes).

Testing: Unit tests were created to ensure the CSS region of an HTML document would be embedded appropriately based on the changes. An HTML file containing tags with style attributes and HTML escaped quotes was also made in the build to test the changes. Along with the lack of errors, clicking and hovering over the CSS region in the style attribute verifies the expected behavior.

image

@iamdereky
Copy link
Contributor Author

@microsoft-github-policy-service agree

assertEmbeddedLanguageContent('<div onKeyUp=return\n/><script>foo();</script>', 'javascript', ' return;\n foo(); ');
});

test('Script content - HTML escape characters', function (): any {
Copy link

@youneshenniwrites youneshenniwrites Dec 5, 2024

Choose a reason for hiding this comment

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

What happens if the input doesn’t contain any escaped quotes? It might be worth adding a test to confirm the input is returned unmodified.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the feedback! I will add another test to confirm this expectation.

Copy link

@youneshenniwrites youneshenniwrites left a comment

Choose a reason for hiding this comment

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

LGTM 👍🏼

@vs-code-engineering vs-code-engineering bot added this to the January 2025 milestone Dec 6, 2024
@aeschli
Copy link
Contributor

aeschli commented Dec 6, 2024

Thanks @iamdereky ! Nice work!

@aeschli aeschli merged commit b3da47c into microsoft:main Dec 9, 2024
7 checks passed
@vs-code-engineering vs-code-engineering bot locked and limited conversation to collaborators Jan 23, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[html] CSS in HTML does not handle escaped quotes

5 participants