File tree Expand file tree Collapse file tree 5 files changed +40
-3
lines changed
Expand file tree Collapse file tree 5 files changed +40
-3
lines changed Original file line number Diff line number Diff line change 2525 "nette/php-generator" : " ^4.1.6" ,
2626 "nikic/php-parser" : " ^5.3" ,
2727 "php" : " ^8.4" ,
28- "psr-discovery/http-client-implementations" : " ^1.4 " ,
29- "psr-discovery/http-factory-implementations" : " ^1.2 " ,
28+ "psr-discovery/http-client-implementations" : " ^1.2 " ,
29+ "psr-discovery/http-factory-implementations" : " ^1.4 " ,
3030 "psr/cache" : " ^3.0" ,
3131 "psr/clock" : " ^1.0.0" ,
3232 "psr/http-client" : " ^1.0.0" ,
3333 "psr/http-factory" : " ^1.0" ,
3434 "psr/http-message" : " ^1.0|^2.0" ,
3535 "psr/log" : " ^3.0.0" ,
36- "rector/rector" : " ^ 2.1" ,
36+ "rector/rector" : " 2. 2.1" ,
3737 "symfony/cache" : " ^7.3" ,
3838 "symfony/mailer" : " ^7.2.6" ,
3939 "symfony/process" : " ^7.3" ,
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Tempest \View \Exceptions ;
4+
5+ use Exception ;
6+
7+ final class AttributesWithSingleQuotesWereNotAllowed extends Exception
8+ {
9+ }
Original file line number Diff line number Diff line change 22
33namespace Tempest \View \Parser ;
44
5+ use Tempest \View \Exceptions \AttributesWithSingleQuotesWereNotAllowed ;
6+
57final class TempestViewLexer
68{
79 private const string WHITESPACE = PHP_EOL . "\n\t\f " ;
@@ -131,6 +133,10 @@ private function lexTag(): array
131133 );
132134
133135 if ($ hasValue ) {
136+ if ($ this ->seek () === '\'' ) {
137+ throw new AttributesWithSingleQuotesWereNotAllowed ();
138+ }
139+
134140 $ attributeValue = $ this ->consumeIncluding ('" ' );
135141 $ attributeValue .= $ this ->consumeIncluding ('" ' );
136142
Original file line number Diff line number Diff line change 44
55use PHPUnit \Framework \Attributes \TestWith ;
66use PHPUnit \Framework \TestCase ;
7+ use Tempest \View \Exceptions \AttributesWithSingleQuotesWereNotAllowed ;
78use Tempest \View \Parser \TempestViewLexer ;
89use Tempest \View \Parser \Token ;
910use Tempest \View \Parser \TokenCollection ;
@@ -346,6 +347,17 @@ public function test_xml(): void
346347 );
347348 }
348349
350+ public function test_single_quote_attributes (): void
351+ {
352+ $ html = <<<HTML
353+ <div class='hello'></div>
354+ HTML ;
355+
356+ $ this ->expectException (AttributesWithSingleQuotesWereNotAllowed::class);
357+
358+ new TempestViewLexer ($ html )->lex ();
359+ }
360+
349361 private function assertTokens (array $ expected , TokenCollection $ actual ): void
350362 {
351363 $ this ->assertCount (count ($ expected ), $ actual );
Original file line number Diff line number Diff line change 55namespace Tests \Tempest \Integration \View ;
66
77use Tempest \Support \Html \HtmlString ;
8+ use Tempest \View \Exceptions \AttributesWithSingleQuotesWereNotAllowed ;
89use Tempest \View \Exceptions \ElementWasInvalid ;
910use Tempest \View \ViewCache ;
1011use Tests \Tempest \Fixtures \Controllers \RelativeViewController ;
@@ -847,4 +848,13 @@ public function test_parse_rss_feed(): void
847848 </feed>
848849 RSS, $ parsed );
849850 }
851+
852+ public function test_attributes_with_single_quotes (): void
853+ {
854+ $ this ->expectException (AttributesWithSingleQuotesWereNotAllowed::class);
855+
856+ $ html = $ this ->render (<<<'HTML'
857+ <div class='hello'></div>
858+ HTML);
859+ }
850860}
You can’t perform that action at this time.
0 commit comments