File tree Expand file tree Collapse file tree 2 files changed +24
-1
lines changed
library/HTMLPurifier/AttrDef/HTML Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -19,9 +19,10 @@ class HTMLPurifier_AttrDef_HTML_Bool2 extends HTMLPurifier_AttrDef_HTML_Bool
1919 */
2020 public function validate ($ string , $ config , $ context )
2121 {
22+ $ name = $ this ->name ? : $ context ->get ('CurrentAttr ' );
2223 // boolean attribute validates if its value is either empty
2324 // or case-insensitively equal to attribute name
24- return $ string === '' || strcasecmp ($ this -> name , $ string ) === 0 ;
25+ return $ string === '' || strcasecmp ($ name , $ string ) === 0 ;
2526 }
2627
2728 /**
Original file line number Diff line number Diff line change @@ -95,4 +95,26 @@ public function testVideo($input)
9595
9696 $ this ->assertEquals ($ input , $ output );
9797 }
98+
99+ public function boolAttrInput ()
100+ {
101+ return array (
102+ array ('<audio controls src="audio.ogg"></audio> ' , '<audio controls src="audio.ogg"></audio> ' ),
103+ array ('<audio controls="" src="audio.ogg"></audio> ' , '<audio controls src="audio.ogg"></audio> ' ),
104+ array ('<audio controls="controls" src="audio.ogg"></audio> ' , '<audio controls src="audio.ogg"></audio> ' ),
105+ array ('<audio controls="CoNtRoLs" src="audio.ogg"></audio> ' , '<audio controls src="audio.ogg"></audio> ' ),
106+ array ('<audio controls="bar" src="audio.ogg"></audio> ' , '<audio src="audio.ogg"></audio> ' ),
107+ );
108+ }
109+
110+ /**
111+ * @dataProvider boolAttrInput
112+ * @depends testAudio
113+ */
114+ public function testBoolAttr ($ input , $ expectedOuptut )
115+ {
116+ $ output = $ this ->getPurifier ()->purify ($ input );
117+
118+ $ this ->assertEquals ($ expectedOuptut , $ output );
119+ }
98120}
You can’t perform that action at this time.
0 commit comments