Message info
 
To:wp-svn@lists.automattic.com From:m@wordpress.org Subject:[wp-svn] [20910] trunk/wp-includes/class-wp-customize-manager.php: Theme Customizer: Improve hex color sanitization functions. Date:Fri, 25 May 2012 18:54:57 +0000 (UTC)
 

Revision
20910
Author
koopersmith
Date
2012-05-25 18:54:57 +0000 (Fri, 25 May 2012)

Log Message

Theme Customizer: Improve hex color sanitization functions. fixes #20600, see #19910.

Instead of fetching default header_textcolor manually, return null to do so automatically.
Improve hex regex.

Modified Paths

Diff

Modified: trunk/wp-includes/class-wp-customize-manager.php (20909 => 20910)


--- trunk/wp-includes/class-wp-customize-manager.php	2012-05-25 18:52:13 UTC (rev 20909)
+++ trunk/wp-includes/class-wp-customize-manager.php	2012-05-25 18:54:57 UTC (rev 20910)
@@ -846,10 +846,7 @@
 
 // Callback function for sanitizing the header textcolor setting.
 function sanitize_header_textcolor( $color ) {
-	if ( empty( $color ) )
-		return get_theme_support( 'custom-header', 'default-text-color' );
-
-	elseif ( $color == 'blank' )
+	if ( $color == 'blank' )
 		return 'blank';
 
 	return sanitize_hexcolor( $color );
@@ -859,8 +856,9 @@
 function sanitize_hexcolor( $color ) {
 	$color = preg_replace( '/[^0-9a-fA-F]/', '', $color );
 
-	if ( preg_match('|[A-Fa-f0-9]{3,6}|', $color ) )
+	// 3 or 6 hex digits.
+	if ( preg_match('|^([A-Fa-f0-9]{3}){1,2}$|', $color ) )
 		return $color;
 
-	return $color;
+	return null;
 }