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

Element with bgcolor attribute creates critical error #38

Closed
bagofarms opened this issue Oct 18, 2022 · 1 comment · Fixed by #39
Closed

Element with bgcolor attribute creates critical error #38

bagofarms opened this issue Oct 18, 2022 · 1 comment · Fixed by #39

Comments

@bagofarms
Copy link
Contributor

When phpally grabs the style of an element, the following condition is evaluated: https://github.com/cidilabs/phpally/blob/master/src/Rule/BaseRule.php#L170

if($element->hasAttribute('bgcolor') &&  in_array($element->tagName, $this->deprecated_style_elements)) {
	$style['background-color'] = $element->getAttribute('bgcolor');
}

If the element does not have a bgcolor attribute, php does not evaluate the second part of the condition, and the code continues executing without issue. If the element does have a bgcolor attribute, the in_array portion of the condition is evaluated, causing a critical error:

Uncaught PHP Exception TypeError: "in_array(): Argument #2 ($haystack) must be of type array, null given" at /var/www/html/vendor/cidilabs/phpally/src/Rule/BaseRule.php line 169

Which appears to be saying that $this->deprecated_style_elements is null. I did a search for deprecated_style_elements in the rest of the codebase, and did not find another mention of it, so it appears that this value is never defined, hence why it is null. It seems like the in_array check isn't really necessary, since it shouldn't matter what element we're pulling the bgcolor attribute from.

@bagofarms
Copy link
Contributor Author

In the course that was exhibiting this issue, I removed all instances of the bgcolor attribute and the UDOIT scan was able to complete successfully.

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 a pull request may close this issue.

1 participant