| @@ -1685,10 +1685,45 @@ | ||
| 1685 | 1685 | */ |
| 1686 | 1686 | public function validate_text_post( $post_key ) { |
| 1687 | 1687 | return self::validate_text_post_static( $post_key ); |
| 1688 | 1688 | } |
| 1689 | - | |
| 1690 | - | |
| 1689 | + | |
| 1690 | + // FixIn: 10.14.2.2 | |
| 1691 | + /** | |
| 1692 | + * Validate Color: '#ff00ff' in POST request - escape data correctly. | |
| 1693 | + * | |
| 1694 | + * @param string $post_key - key for POST | |
| 1695 | + * @return string | false, if no such POST | |
| 1696 | + */ | |
| 1697 | + public function validate_color_post( $post_key ) { | |
| 1698 | + return self::validate_color_static( $post_key ); | |
| 1699 | + } | |
| 1700 | + | |
| 1701 | + | |
| 1702 | + // FixIn: 10.14.2.2 | |
| 1703 | + /** | |
| 1704 | + * Static Validate Color field in POST request - escape data correctly. | |
| 1705 | + * | |
| 1706 | + * @param string $post_key - key for POST | |
| 1707 | + * @return string | false, if no such POST | |
| 1708 | + */ | |
| 1709 | + public static function validate_color_static( $post_key ) { | |
| 1710 | + | |
| 1711 | + $value = ''; | |
| 1712 | + | |
| 1713 | + // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing | |
| 1714 | + if ( isset( $_POST[ $post_key ] ) ) { | |
| 1715 | + // phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized | |
| 1716 | + $value = sanitize_hex_color( trim( stripslashes( $_POST[ $post_key ] ) ) ); | |
| 1717 | + if ( null === $value ) { | |
| 1718 | + $value = ''; | |
| 1719 | + } | |
| 1720 | + } | |
| 1721 | + | |
| 1722 | + return $value; | |
| 1723 | + } | |
| 1724 | + | |
| 1725 | + | |
| 1691 | 1726 | /** |
| 1692 | 1727 | * Static Validate Text in POST request - escape data correctly. |
| 1693 | 1728 | * |
| 1694 | 1729 | * @param string $post_key - key for POST |