File tree Expand file tree Collapse file tree 3 files changed +57
-3
lines changed Expand file tree Collapse file tree 3 files changed +57
-3
lines changed Original file line number Diff line number Diff line change 1717 </ItemGroup >
1818
1919 <ItemGroup >
20- <PackageReference Include =" Microsoft.NET.Test.Sdk" Version =" 15.3.0 " />
21- <PackageReference Include =" xunit.runner.visualstudio" Version =" 2.2 .0" />
22- <PackageReference Include =" xunit" Version =" 2.2 .0" />
20+ <PackageReference Include =" Microsoft.NET.Test.Sdk" Version =" 17.6.3 " />
21+ <PackageReference Include =" xunit.runner.visualstudio" Version =" 2.5 .0" />
22+ <PackageReference Include =" xunit" Version =" 2.5 .0" />
2323 </ItemGroup >
2424
2525 <ItemGroup >
Original file line number Diff line number Diff line change 11using System ;
2+ using System . Threading ;
23
34namespace ExCSS . Tests
45{
@@ -920,6 +921,54 @@ public void CssParseSheetWithTwoStyleAndMediaRule()
920921 Assert . Equal ( RuleType . Media , sheet . Rules [ 2 ] . Type ) ;
921922 }
922923
924+ [ Fact ( Timeout = 1000 ) ]
925+ public void CssParseSheetWithAtAndCommentDoesNotTakeForever ( )
926+ {
927+ var sheet = ParseStyleSheet ( @"
928+ h3 {color: yellow;
929+ @media print {
930+ h3 {color: black; }
931+ }
932+ " ) ;
933+ Assert . Equal ( 1 , sheet . Rules . Length ) ;
934+ Assert . Equal ( RuleType . Style , sheet . Rules [ 0 ] . Type ) ;
935+ }
936+
937+ [ Fact ( Timeout = 1000 ) ]
938+ public void CssParseSheetWithAtAndCommentDoesNotTakeForever2 ( )
939+ {
940+ var sheet = ParseStyleSheet ( @"
941+ :root {
942+ --layout: {
943+ }
944+ --layout-horizontal: {
945+ @apply (--layout);
946+ }
947+ }" ) ;
948+ Assert . Equal ( 1 , sheet . Rules . Length ) ;
949+ Assert . Equal ( RuleType . Style , sheet . Rules [ 0 ] . Type ) ;
950+ }
951+
952+ [ Fact ( Timeout = 1000 ) ]
953+ public void CssParseSheetWithAtAndCommentDoesNotTakeForever3 ( )
954+ {
955+ var sheet = ParseStyleSheet ( @"
956+ @media (max-width: 991px) {
957+ body {
958+ background-color: #013668;
959+ }
960+ ;
961+ }
962+
963+ @media (max-width: 991px) {
964+ body {
965+ background: #FFF;
966+ }
967+ }" ) ;
968+ Assert . Equal ( 1 , sheet . Rules . Length ) ;
969+ Assert . Equal ( RuleType . Media , sheet . Rules [ 0 ] . Type ) ;
970+ }
971+
923972 [ Fact ]
924973 public void CssParseImportStatementWithNoMediaTextFollowedByStyle ( )
925974 {
Original file line number Diff line number Diff line change @@ -551,6 +551,11 @@ public TextPosition FillDeclarations(StyleDeclaration style)
551551 parentPageRule . AppendChild ( marginStyle ) ;
552552 token = marginToken ;
553553 }
554+ else
555+ {
556+ // Advance to the next token or this is an endless loop
557+ token = _lexer . Get ( ) ;
558+ }
554559 }
555560 else
556561 {
You can’t perform that action at this time.
0 commit comments