`ToCss` returns unescaped property names
MartinWelsch opened this issue · comments
MartinWelsch commented
Bug Report
Prerequisites
- Can you reproduce the problem in a MWE?
- Are you running the latest version of AngleSharp?
- Did you check the FAQs to see if that helps you?
- Are you reporting to the correct repository? (there are multiple AngleSharp libraries, e.g.,
AngleSharp.Css
for CSS support) - Did you perform a search in the issues?
For more information, see the CONTRIBUTING
guide.
Description
Consider the followig program:
using System;
using AngleSharp;
using AngleSharp.Css.Parser;
public class Program
{
public static void Main()
{
const string stylesheetText = @".className { --\/prop: value; }";
var parser = new CssParser();
var style = parser.ParseStyleSheet(stylesheetText);
Console.WriteLine(style.ToCss());
// prints:
// .className { --/prop: value }
}
}
The property named --/prop
is written literally which results in invalid CSS.
Expected behavior: style.ToCss()
to return .className { --\/prop: value }
Actual behavior: style.ToCss()
returned .className { --/prop: value }
Environment details: .NET6, AngleSharp.Css 0.16.4
Possible Solution
CssProperty should escape Name
using CssUtilities.Escape(Name)