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