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

improve sanitization in jetpack_amp_build_stats_pixel_url() #1000

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion jetpack-helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ function jetpack_amp_build_stats_pixel_url() {
$data = compact( 'v', 'j', 'blog', 'post', 'tz', 'srv' );
}

$data['host'] = isset( $_SERVER['HTTP_HOST'] ) ? rawurlencode( $_SERVER['HTTP_HOST'] ) : ''; // input var ok
$data['host'] = isset( $_SERVER['HTTP_HOST'] ) ? sanitize_text_field( wp_unslash( $_SERVER['HTTP_HOST'] ) ) : ''; // input var ok
Copy link
Member

Choose a reason for hiding this comment

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

sanitize_text_field is not equivalent to rawurlencode

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Does rawurlencode() count as a sanitizing function? If not, should another one be used? If not, should WPCS be updated?

Copy link
Member

Choose a reason for hiding this comment

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

Nevermind. I supose this change is ok. You can cherry-pick this into #1002 as well.

$data['rand'] = 'RANDOM'; // amp placeholder
$data['ref'] = 'DOCUMENT_REFERRER'; // amp placeholder
$data = array_map( 'rawurlencode' , $data );
Expand Down