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

ErrorException #1 htmlspecialchars() expects parameter 1 to be string #702

Closed
malayvuong opened this issue Sep 1, 2017 · 6 comments
Closed

Comments

@malayvuong
Copy link

I have this error Exception. I wonder why i received this error and how to fix it. I decided to delete this display full error detail.

screen shot 2017-09-01 at 13 28 06

<?php if (! is_array($value) && ! is_object($value)) : ?>
<?= htmlspecialchars($value, ENT_SUBSTITUTE, 'UTF-8') ?>  // Delete this line
<?php else: ?>
<?= '<pre>'.print_r($value, true) ?>
<?php endif; ?>

When i delete this line ci4/application/Views/errors/html/error_exception.php(149): htmlspecialchars(Object(__PHP_Incomplete_Class), 8, 'UTF-8') so this error has display normally.

After i delete this line, result like this:
screen shot 2017-09-01 at 13 35 24

Does this negatively affect the display of errors?

@InsiteFX
Copy link
Contributor

InsiteFX commented Sep 1, 2017

htmlspecialchars takes 4 parameters. the last ones are optional.

So echo out your $value and see if it is a string.

@malayvuong
Copy link
Author

malayvuong commented Sep 3, 2017

I don't know how. I'm from Vietnam, so in my php file, sometime I comment or texture has some Vietnamese in theres.
When I echo $value, this is the result:
screen shot 2017-09-03 at 22 09 20

@InsiteFX
Copy link
Contributor

InsiteFX commented Sep 3, 2017

Shouldn't your auth.html be named auth.php ?

@malayvuong
Copy link
Author

I don't think so, .html just an extension for the url.
When I echo an invalid variable; this error displayed.

@lonnieezell
Copy link
Member

A better option than deleting the line (and the potential protections they give) is to try and fix it. Not sure how an object was getting through when we were checking to ensure it wasn't an object, but that's no biggie. I've changed it to check if it's a string which should keep us safe. Try again and let me know how it works for you.

@malayvuong
Copy link
Author

It's work!

Thanks.

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

No branches or pull requests

3 participants