diff --git a/src/CssLint/Linter.php b/src/CssLint/Linter.php index 6250594..2fc69d9 100644 --- a/src/CssLint/Linter.php +++ b/src/CssLint/Linter.php @@ -505,7 +505,7 @@ protected function lintImportChar(string $charValue): ?bool if ($this->assertContext(self::CONTEXT_SELECTOR) && str_starts_with($this->getContextContent(), '@import')) { $this->addContextContent($charValue); - if ($charValue === ';') { + if ($charValue === ';' && $this->assertPreviousChar(')')) { $this->resetContext(); return true; } diff --git a/tests/TestSuite/LinterTest.php b/tests/TestSuite/LinterTest.php index d5389bd..a325947 100644 --- a/tests/TestSuite/LinterTest.php +++ b/tests/TestSuite/LinterTest.php @@ -201,5 +201,20 @@ public function testLintValidImportRule() $this->linter->lintString("@import url('https://fonts.googleapis.com/css2?family=Poppins&display=swap');"), print_r($this->linter->getErrors(), true) ); + + $this->assertTrue( + $this->linter->lintString("@import url('https://fonts.googleapis.com/css2?family=Comic+Neue:ital,wght@0,300;0,400;0,700;1,300;1,400;1,700&display=swap');"), + print_r($this->linter->getErrors(), true) + ); + } + + public function testLintNotValidImportRule() + { + $this->assertFalse( + $this->linter->lintString("@import url('"), + ); + $this->assertSame([ + 'Unterminated "selector" (line: 1, char: 13)', + ], $this->linter->getErrors()); } }