[vlc-commits] [Git][videolan/vlc][master] codec: webvtt: fix !important declaration

François Cartegnie (@fcartegnie) gitlab at videolan.org
Mon Sep 28 06:18:41 UTC 2026



François Cartegnie pushed to branch master at VideoLAN / VLC


Commits:
a321f97f by François Cartegnie at 2026-09-28T08:04:19+02:00
codec: webvtt: fix !important declaration

fixes #30129

- - - - -


3 changed files:

- modules/codec/webvtt/CSSGrammar.y
- modules/codec/webvtt/CSSLexer.l
- modules/codec/webvtt/css_test.c


Changes:

=====================================
modules/codec/webvtt/CSSGrammar.y
=====================================
@@ -78,7 +78,7 @@ static void yyerror(yyscan_t scanner, vlc_css_parser_t *p, const char *msg)
 
 %}
 
-%expect 7
+%expect 5
 
 %nonassoc LOWEST_PREC
 
@@ -743,14 +743,14 @@ expr:
         if( !vlc_css_expression_AddTerm( $1, ' ', $2 ) )
             YYNOMEM;
     }
-    | expr operator maybe_space term {
+    | expr operator term {
         if( !$1 )
         {
             $$ = NULL;
             YYERROR;
         }
         $$ = $1;
-        if( !vlc_css_expression_AddTerm( $1, '/', $4 ) )
+        if( !vlc_css_expression_AddTerm( $1, $2, $3 ) )
             YYNOMEM;
     }
   ;


=====================================
modules/codec/webvtt/CSSLexer.l
=====================================
@@ -77,7 +77,7 @@ range		\?{1,6}|{h}(\?{0,5}|{h}(\?{0,4}|{h}(\?{0,3}|{h}(\?{0,2}|{h}(\??|{h})))))
 
 "@font-face"		{return FONT_FACE_SYM;}
 
-"!{w}important"		{return IMPORTANT_SYM;}
+"!"{w}important		{return IMPORTANT_SYM;}
 
 {num}em			{ VAL( vlc_strtof_c(yytext, &d), EMS ); return LENGTH;}
 {num}ex			{ VAL( atoi(yytext), EXS ); return LENGTH;}


=====================================
modules/codec/webvtt/css_test.c
=====================================
@@ -425,6 +425,55 @@ error:
     return 1;
 }
 
+static int test_important_and_operators(void)
+{
+    const char *css =
+        "values {"
+        "  important-compact: red!important;"
+        "  important-spaced: blue ! important;"
+        "  slash: 1 / 2;"
+        "  comma: foo, bar;"
+        "}\n";
+
+    PARSE_CSS("test_important_and_operators");
+
+    CHECK("important and operators");
+    EXPECT(rule && rule->b_valid);
+
+    const vlc_css_declaration_t *decl = rule->p_declarations;
+
+    EXPECT(decl && !strcmp(decl->psz_property, "important-compact"));
+    EXPECT(decl->expr && decl->expr->i_count == 1);
+    EXPECT(decl->expr->seq[0].term.type == TYPE_IDENTIFIER);
+    EXPECT(!strcmp(decl->expr->seq[0].term.psz, "red"));
+
+    decl = decl->p_next;
+    EXPECT(decl && !strcmp(decl->psz_property, "important-spaced"));
+    EXPECT(decl->expr && decl->expr->i_count == 1);
+    EXPECT(decl->expr->seq[0].term.type == TYPE_IDENTIFIER);
+    EXPECT(!strcmp(decl->expr->seq[0].term.psz, "blue"));
+
+    decl = decl->p_next;
+    EXPECT(decl && !strcmp(decl->psz_property, "slash"));
+    EXPECT(decl->expr && decl->expr->i_count == 2);
+    EXPECT(decl->expr->seq[1].op == '/');
+
+    decl = decl->p_next;
+    EXPECT(decl && !strcmp(decl->psz_property, "comma"));
+    EXPECT(decl->expr && decl->expr->i_count == 2);
+    EXPECT(decl->expr->seq[1].op == ',');
+
+    EXPECT(!decl->p_next);
+
+    vlc_css_parser_Clean(&p);
+    return 0;
+
+error:
+    vlc_css_parser_Clean(&p);
+    return 1;
+}
+
+
 static int test_error_cases(void)
 {
     const char *css =
@@ -476,5 +525,6 @@ int main(void)
            test_pseudo_selectors() ||
            test_combinators() ||
            test_values() ||
+           test_important_and_operators() ||
            test_error_cases();
 }



View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/a321f97f92f325344fd0352dcbfc03b0b6956c7e

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/a321f97f92f325344fd0352dcbfc03b0b6956c7e
You're receiving this email because of your account on code.videolan.org. Manage all notifications: https://code.videolan.org/-/profile/notifications | Help: https://code.videolan.org/help




More information about the vlc-commits mailing list