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

Fix/plugin checks #2654

Merged
merged 214 commits into from
May 30, 2024
Merged

Fix/plugin checks #2654

merged 214 commits into from
May 30, 2024

Conversation

brianhogg
Copy link
Contributor

@brianhogg brianhogg commented May 13, 2024

Description

Various security warning/error fixes.

How has this been tested?

Manually

Checklist:

  • This PR requires and contains at least one changelog file.
  • My code has been tested.
  • My code passes all existing automated tests.
  • My code follows the LifterLMS Coding & Documentation Standards.

Copy link
Member

@ideadude ideadude left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly minor stuff and some cases where I'd like to double check that we're sure there isn't supposed to be HTML in things we're using esc_html on. A few cases of CSS/style code that I believe breaks when escaped sometimes.

Some places where you used esc_attr__, where I would have used esc_html__. These functions are literally the same, except for the filter applied. But good to only use the attribute one for html attributes as far as I know.

https://github.com/WordPress/WordPress/blob/9702c2e265bd3aff0522f55063d97ca21cc70099/wp-includes/formatting.php#L4673-L4721

includes/admin/settings/class.llms.settings.checkout.php Outdated Show resolved Hide resolved
@@ -327,18 +324,16 @@ public function get_table_html( $rows ) {

ob_start();
?>
<table style="<?php echo $table_style; ?>">
<table style="<?php echo esc_attr( $table_style ); ?>">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How can we test this. I feel these styles and content may include things broken by the escaping functions.

includes/class.llms.install.php Outdated Show resolved Hide resolved
includes/class.llms.install.php Outdated Show resolved Hide resolved
includes/class.llms.post.relationships.php Outdated Show resolved Hide resolved
includes/forms/class-llms-forms-unsupported-versions.php Outdated Show resolved Hide resolved
data-handler="<?php echo $this->get_handler(); ?>"
id="llms-gb-table-<?php echo $this->id; ?>"
class="<?php echo esc_attr( implode( ' ', $classes ) ); ?>"
data-args='<?php echo esc_attr( wp_json_encode( $this->get_args() ) ); ?>'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should be good to esc_attr this even though wp_json_encode() should be safe

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. esc_attr and esc_html don't seem to interfere with the json as used here and similar places.

brianhogg and others added 7 commits May 14, 2024 10:08
Co-authored-by: Jason Coleman <33220397+ideadude@users.noreply.github.com>
Co-authored-by: Jason Coleman <33220397+ideadude@users.noreply.github.com>
Co-authored-by: Jason Coleman <33220397+ideadude@users.noreply.github.com>
Co-authored-by: Jason Coleman <33220397+ideadude@users.noreply.github.com>
Co-authored-by: Jason Coleman <33220397+ideadude@users.noreply.github.com>
…tudents.php

Co-authored-by: Jason Coleman <33220397+ideadude@users.noreply.github.com>
…tudents.php

Co-authored-by: Jason Coleman <33220397+ideadude@users.noreply.github.com>
<?php if ( $selected_gateway->get_icon() ) : ?>
<span class="llms-gateway-icon"><?php echo $selected_gateway->get_icon(); ?></span>
<span class="llms-gateway-icon"><?php echo wp_kses_post( $selected_gateway->get_icon() ); ?></span>
Copy link
Contributor Author

@brianhogg brianhogg May 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes or something up the chain are breaking some of the checkout functionality. The icons beside gateways don't appear (ie. credit card images, "powered by stripe" for credit card, and the first gateway isn't checked by default (but is bolded)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding additional tags and attributes to the LLMS_Form_Field::render() array for wp_kses() seems to have solved the output. It's part of the icon property on the form field which gets combined into the description, and it was being stripped out (img and an a tag)

@brianhogg brianhogg marked this pull request as ready for review May 30, 2024 13:48
@brianhogg brianhogg merged commit abc2d31 into dev May 30, 2024
31 checks passed
@brianhogg brianhogg deleted the fix/plugin-checks branch May 30, 2024 14:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

2 participants