@@ -31,4 +31,67 @@ public function test_esc_attr_amp() {
3131 $ out = esc_attr ( 'foo & bar &baz; ' );
3232 $ this ->assertSame ( 'foo & bar &baz; ' , $ out );
3333 }
34+
35+ /**
36+ * Verifies the conversion of various kinds of decimal numeric references.
37+ *
38+ * @ticket {TICKET_NUMBER}
39+ *
40+ * @dataProvider data_decimal_numeric_references
41+ *
42+ * @param string $input Attribute value with decimal character references.
43+ * @param string $output How WordPress is expected to transform the attribute value.
44+ */
45+ public function test_converts_decimal_numeric_references ( $ input , $ output ) {
46+ $ this ->assertSame ( $ output , esc_attr ( $ input ), 'Failed to properly convert input. ' );
47+ }
48+
49+ /**
50+ * Data provider.
51+ *
52+ * @return array[].
53+ */
54+ public function data_decimal_numeric_references () {
55+ return array (
56+ 'Basic decimal ' => array ( '‣ ' , '‣ ' ),
57+ 'Control character ' => array ( ' ' , ' ' ),
58+ 'Leading zeros ' => array ( 'A ' , 'A ' ),
59+ 'Leading zeros on \'' => array ( '' ' , '' ' ),
60+ 'Leading zero on \'' => array ( '' ' , '' ' ),
61+ 'Surrogate half ' => array ( '� ' , '� ' ),
62+ 'Code point too high ' => array ( '� ' , '� ' ),
63+ );
64+ }
65+
66+ /**
67+ * Verifies the conversion of various kinds of hexadecimal numeric references.
68+ *
69+ * @ticket {TICKET_NUMBER}
70+ *
71+ * @dataProvider data_hexadecimal_numeric_references
72+ *
73+ * @param string $input Attribute value with hexadecimal character references.
74+ * @param string $output How WordPress is expected to transform the attribute value.
75+ */
76+ public function test_converts_hexadecimal_numeric_references ( $ input , $ output ) {
77+ $ this ->assertSame ( $ output , esc_attr ( $ input ), 'Failed to properly convert input. ' );
78+ }
79+
80+ /**
81+ * Data provider.
82+ *
83+ * @return array[].
84+ */
85+ public function data_hexadecimal_numeric_references () {
86+ return array (
87+ 'Basic lower hex ' => array ( '‣ ' , '‣ ' ),
88+ 'Basic upper hex ' => array ( '‣ ' , '‣ ' ),
89+ 'Control character ' => array ( ' ' , ' ' ),
90+ 'Leading zeros ' => array ( 'e ' , 'e ' ),
91+ 'Leading zeros on \'' => array ( '' ' , '' ' ),
92+ 'Leading zero on \'' => array ( '' ' , '' ' ),
93+ 'Surrogate half ' => array ( '� ' , '� ' ),
94+ 'Code point too high ' => array ( ' ' , ' ' ),
95+ );
96+ }
3497}
0 commit comments