Skip to content

Conversation

@xHeaven
Copy link
Contributor

@xHeaven xHeaven commented Jun 17, 2025

Problem

When parsing HTML comments, any 0 character (like in URLs such as http://www.w3.org/2000/svg) was being treated as "false" in PHP. This made the lexer stop parsing too early and break up the comment before it was supposed to.

Root Cause

PHP treats the string "0" as false, so when $this->current === '0', the loop condition fails and exits before finding the actual closing -->.

Fix

We just need to be more specific about checking for null instead of relying on PHP's truthiness:

- while ($this->seek(3) !== '-->' && $this->current) {
+ while ($this->seek(3) !== '-->' && $this->current !== null) {

Explicit null check FTW.

Relates to #1288 (failing PR, merge this first)
Fixes #1287

@innocenzi innocenzi changed the title fix(lexer): fix falsy boolean evaluation on comments fix(view): fix falsy boolean evaluation on comments Jun 18, 2025
@brendt brendt merged commit 8d0d780 into tempestphp:main Jun 23, 2025
68 checks passed
@brendt
Copy link
Member

brendt commented Jun 23, 2025

Thanks for fixing my dumb mistakes :D

So we now need to update #1288, I reckon?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

InvalidClosingTag throwing on commented-out code

2 participants