| 42 | |
| 43 | /** |
| 44 | * Check some of the double-encoding features for entity references. |
| 45 | * |
| 46 | * @ticket 17780 |
| 47 | * @dataProvider data_double_encoding |
| 48 | */ |
| 49 | function test_double_encoding( $input, $output ) { |
| 50 | return $this->assertEquals( $output, _wp_specialchars( $input, ENT_NOQUOTES, false, true ) ); |
| 51 | } |
| 52 | |
| 53 | function data_double_encoding() { |
| 54 | return array( |
| 55 | array( |
| 56 | 'This & that, this & that, — " " Ú " " " " " $ ×', |
| 57 | 'This & that, this & that, — " " Ú   " " " " " $ ×', |
| 58 | ), |
| 59 | array( |
| 60 | '&& && && &;', |
| 61 | '&& && && &;', |
| 62 | ), |
| 63 | array( |
| 64 | '&garbage; &***; &aaaa; &0000; &####; &;;', |
| 65 | '&garbage; &***; &aaaa; &0000; &####; &;;', |
| 66 | ), |
| 67 | array( |
| 68 | '& " —', |
| 69 | '& " —', |
| 70 | ), |
| 71 | ); |
| 72 | } |
| 73 | |
| 74 | /** |
| 75 | * Check some of the double-encoding features for entity references. |
| 76 | * |
| 77 | * @ticket 17780 |
| 78 | * @dataProvider data_no_double_encoding |
| 79 | */ |
| 80 | function test_no_double_encoding( $input, $output ) { |
| 81 | return $this->assertEquals( $output, _wp_specialchars( $input, ENT_NOQUOTES, false, false ) ); |
| 82 | } |
| 83 | |
| 84 | function data_no_double_encoding() { |
| 85 | return array( |
| 86 | array( |
| 87 | 'This & that, this & that, — " " Ú " " " " " $ ×', |
| 88 | 'This & that, this & that, — " " Ú " " " " " $ ×', |
| 89 | ), |
| 90 | array( |
| 91 | '&& && && &;', |
| 92 | '&& && && &;', |
| 93 | ), |
| 94 | array( |
| 95 | '&garbage; &***; &aaaa; &0000; &####; &;;', |
| 96 | '&garbage; &***; &aaaa; &0000; &####; &;;', |
| 97 | ), |
| 98 | array( |
| 99 | '& " —', |
| 100 | '& " —', |
| 101 | ), |
| 102 | ); |
| 103 | } |