@@ -566,7 +566,8 @@ TOKEN :
566
566
<DEFAULT>
567
567
TOKEN :
568
568
{
569
- < CDO : "<!--" >
569
+ < SCO : "/*" >
570
+ | < CDO : "<!--" >
570
571
| < CDC : "-->" >
571
572
| < INCLUDES : <TILDE> "=" >
572
573
| < DASHMATCH : "|=" >
@@ -934,9 +935,18 @@ void afterImportDeclaration() :
934
935
new ParseException(ac.getMsg().getString("parser.import_not_allowed"));
935
936
addError(e, ret);
936
937
} else {
937
- ParseException e =
938
- new ParseException(ac.getMsg().getString("generator.unrecognize"));
939
- addError(e, ret);
938
+ // ignore unterminated comment
939
+ CssVersion version = ac.getCssVersion();
940
+ if (!ret.startsWith("/*") || (version.compareTo(CssVersion.CSS3) < 0)) {
941
+ ParseException e = new ParseException(ac.getMsg().getString("generator.unrecognize"));
942
+ addError(e, ret);
943
+ } else {
944
+ // read until the end
945
+ Token t = getToken(0);
946
+ while(t.kind != EOF) {
947
+ t = getNextToken();
948
+ }
949
+ }
940
950
}
941
951
}
942
952
) ignoreStatement() )*
@@ -2017,8 +2027,47 @@ void ruleSet() :
2017
2027
currentContext = null;
2018
2028
}
2019
2029
} catch (ParseException e) {
2020
- if ((ac.getCssProfile() != CssProfile.MOBILE) && !context_set.isEmpty()) {
2021
- addError(e, skipStatement());
2030
+ if ((ac.getCssProfile() != CssProfile.MOBILE) && !context_set.isEmpty()) {
2031
+ String ret = skipStatement();
2032
+ CssVersion version = ac.getCssVersion();
2033
+ Token t1 = getToken(1);
2034
+ if (version.compareTo(CssVersion.CSS3) < 0) {
2035
+ addError(e, ret);
2036
+ } else if ((ret != null) && !ret.startsWith("/*") && (t1 != null && t1.kind == EOF)) {
2037
+ addError(e, ret);
2038
+ } else {
2039
+ // unterminated comment, skip until EOF
2040
+ Token t = getToken(0);
2041
+ while(t.kind != EOF) {
2042
+ t = getNextToken();
2043
+ }
2044
+ // then process
2045
+ if (version.compareTo(CssVersion.CSS3) >= 0) {
2046
+ markRule = true;
2047
+ if (value_set != null) {
2048
+ boolean first = true;
2049
+ for (CssSelectors sel : context_set) {
2050
+ if (first) {
2051
+ handleRule(sel, value_set);
2052
+ first = false;
2053
+ } else {
2054
+ // we need to duplicate properties in that case
2055
+ // as property holds reference to the selectors and it interact
2056
+ // badly with conflict detection
2057
+ int vsize = value_set.size();
2058
+ ArrayList<CssProperty> v = new ArrayList<CssProperty>(vsize);
2059
+ for (CssProperty p : value_set) {
2060
+ v.add(p.duplicate());
2061
+ }
2062
+ handleRule(sel, v);
2063
+ }
2064
+ }
2065
+ setSelectorList(context_set);
2066
+ endOfRule();
2067
+ }
2068
+ }
2069
+ currentContext = null;
2070
+ }
2022
2071
}
2023
2072
} catch (TokenMgrError e) {
2024
2073
addError(new ParseException(e.getMessage()), skipStatement());
0 commit comments