Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[11.x] Handle HtmlString constructed with a null #53367

Merged

Conversation

sperelson
Copy link
Contributor

I managed to construct an HtmlString with a null value. I realise that inserting a null value into an HtmlString is pretty bad and I should have sanitized the value properly beforehand.

However, since this is possible, I believe that the __toString() and isEmpty methods should gracefully handle null values. This will prevent a type error exception when getting the string value and correctly reflect that the HtmlString is empty.

@rodrigopedra
Copy link
Contributor

I should have sanitized the value properly beforehand.

Yes. HtmlString's constructor type hint (in its docblock) says it only deals with strings.

Even if parameters type hints were used, you'd have to sanitize any values before passing down to the constructor.

@taylorotwell taylorotwell merged commit db76573 into laravel:11.x Nov 1, 2024
33 checks passed
@sperelson sperelson deleted the Handle-HtmlString-with-null-value branch November 1, 2024 23:25
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.

3 participants