Opened 7 years ago
Closed 3 months ago
#45168 closed defect (bug) (duplicate)
Additional CSS complains of markup inside CSS comments
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Priority: | normal | |
| Severity: | normal | Version: | 4.7 |
| Component: | Customize | Keywords: | needs-patch |
| Focuses: | Cc: |
Description
When adding CSS to a site via Appearance > Customize > Additional CSS, the syntax validator will complain if it finds markup regardless of it being inside a /* */ comment.
Steps to replicate:
- Go to Admin > Appearance > Customize > Additional CSS
- Add a comment with some markup in it
/* this is <a> markup test */
- Hit Publish
- See attached error message - but note that no indicator as to what line contains the markup appears.
The only workaround is to remove the markup from the comment.
Ideally the syntax validator should not care about anything in CSS comment blocks.
Attachments (1)
Change History (8)
#2
@
6 years ago
- Keywords needs-patch added
- Milestone changed from Awaiting Review to Future Release
- Version changed from 4.9.8 to 4.7
#3
@
5 years ago
Most of the PHP validation for Additional CSS was replaced in [41376], but the check for the existence of an HTML tag (pattern) is still there.
https://core.trac.wordpress.org/browser/tags/5.5/src/wp-includes/customize/class-wp-customize-custom-css-setting.php#L162
If keeping the tag check in PHP, it would need to make sure all matches to that pattern are not inside comments to pass the validation.
Technically, though, there are workarounds. Currently acceptable methods include adding a space after the first angle bracket or replacing the angle brackets with Markdown-style inline code syntax.
/* comment with < a > tag */ /* comment with `a` tag */
#4
@
5 years ago
The HTML validation is in place for security reasons (at least originally). I believe the primary It might be possible to allow it when specifically scoped within comments, as long as there's a secure way to enforce that check.
#5
@
8 months ago
- Keywords close 2nd-opinion added
This does not have a patch yet, and it involves a regular expression. I recommend closing the ticket.
#6
@
3 months ago
- Keywords close 2nd-opinion removed
In comment:3:ticket:64418, @westonruter suggested editing how the CSS is validated.
Error message regarding markup inside CSS comment