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

Add exception output escaping for the Color library. #38385

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
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
28 changes: 24 additions & 4 deletions projects/plugins/jetpack/_inc/lib/class.color.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,30 @@ public function fromHex( $hex_value ) {
*/
public function fromRgbInt( $red, $green, $blue ) {
if ( $red < 0 || $red > 255 ) {
throw new RangeException( 'Red value ' . $red . ' out of valid color code range' );
throw new RangeException(
sprintf(
'Red value %s out of valid color code range',
esc_html( $red )
)
);
}

if ( $green < 0 || $green > 255 ) {
throw new RangeException( 'Green value ' . $green . ' out of valid color code range' );
throw new RangeException(
sprintf(
'Green value %s out of valid color code range',
esc_html( $green )
)
);
}

if ( $blue < 0 || $blue > 255 ) {
throw new RangeException( 'Blue value ' . $blue . ' out of valid color code range' );
throw new RangeException(
sprintf(
'Blue value %s out of valid color code range',
esc_html( $blue )
)
);
}

$this->color = ( intval( $red ) << 16 ) + ( intval( $green ) << 8 ) + intval( $blue );
Expand Down Expand Up @@ -186,7 +201,12 @@ private function hue2rgb( $p, $q, $t ) {
*/
public function fromInt( $int_value ) {
if ( $int_value < 0 || $int_value > 16777215 ) {
throw new RangeException( $int_value . ' out of valid color code range' );
throw new RangeException(
sprintf(
'%s out of valid color code range',
esc_html( $int_value )
)
);
}

$this->color = $int_value;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: other
Comment: Minor changes that only add output escaping.


Loading