Skip to content

Code Review - Escaping, reference operators, url protocols#107

Closed
christianc1 wants to merge 8 commits into
Automattic:developfrom
christianc1:cchung/chore/code-review
Closed

Code Review - Escaping, reference operators, url protocols#107
christianc1 wants to merge 8 commits into
Automattic:developfrom
christianc1:cchung/chore/code-review

Conversation

@christianc1
Copy link
Copy Markdown
Contributor

Original review was done for @campusinsiders on @wpcomvip by @tomjn.

Figuring the changeset is valuable for others as well, I added some additional missed escaping and put it all together as a pull request.

.org users:
tjnowell (Tom)
christian1012 (me)

Comment thread common/lib/acm-provider.php Outdated
}

echo PHP_EOL;
echo esc_html( PHP_EOL );
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Constants and string literals don't need to be escaped.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

updated in 60c50cf

@christianc1
Copy link
Copy Markdown
Contributor Author

@joshbetz : Following up on this, anything additional I can do to help this along?

@trepmal trepmal mentioned this pull request Jun 4, 2021
@GaryJones GaryJones added this to the 0.6 milestone Mar 14, 2022
@GaryJones GaryJones added the type: maintenance Routine maintenance and code quality improvements label Mar 14, 2022
@GaryJones GaryJones changed the base branch from master to develop March 14, 2022 17:02
Copy link
Copy Markdown
Collaborator

@GaryJones GaryJones left a comment

Choose a reason for hiding this comment

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

I've cherry-picked some of these commits into a new branch, and fixed up the issues I've highlighted.

$output = '<div id="inline_' . $item['post_id'] . '" style="display:none;">';
$output .= '<div class="id">' . $item['post_id'] . '</div>';
$output = '<div id="inline_' . esc_attr( $item['post_id'] ) . '" style="display:none;">';
$output .= '<div class="id">' . esc_attr( $item['post_id'] ) . '</div>';
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This should be esc_html().

public function __construct() {
// Default output HTML
$this->output_html ='<div id="acm-ad-tag-%tag%"><script async src="http://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
$this->output_html ='<div id="acm-ad-tag-%tag%"><script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Protocol-less URLs are an anti-pattern.

//-->
</script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script></div>';
<script type="text/javascript" src="//pagead2.googlesyndication.com/pagead/show_ads.js"></script></div>';
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Protocol-less URLs are an anti-pattern.

<div class="form-field form-required">
<label for="<?php echo esc_attr( $column_id ) ?>"><?php echo esc_html( $arg['label'] ) ?></label>
<input name="<?php echo esc_attr( $column_id ) ?>" id="<?php echo esc_attr( $column_id ) ?>" type="text" value="" size="40" aria-required="<?php echo $arg['required'] ?>">
<input name="<?php echo esc_attr( $column_id ) ?>" id="<?php echo esc_attr( $column_id ) ?>" type="text" value="" size="40" aria-required="<?php echo esc_url( $arg['required'] ); ?>">
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This should be esc_attr().

@GaryJones
Copy link
Copy Markdown
Collaborator

Closing this PR, as the new branch will contain some of the work done in this PR. Thank you for your contribution!

@GaryJones GaryJones closed this Mar 15, 2022
@GaryJones GaryJones removed this from the 0.6 milestone Mar 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: maintenance Routine maintenance and code quality improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants