#!perl
use strict;
use warnings;
use CGI qw/ autoEscape escapeHTML button textfield password_field textarea popup_menu scrolling_list checkbox_group optgroup checkbox radio_group submit image_button button /;
is (button(-name => 'test<'), '<input type="button" name="test<" value="test<" />', "autoEscape defaults to On");
is (button(-name => 'test<'), '<input type="button" name="test<" value="test<" />', "turning off autoescape actually works");
autoEscape(1);
is (button(-name => 'test<'), '<input type="button" name="test<" value="test<" />', "autoescape turns back on");
autoEscape(0);
# RT #25485: Needs Tests: autoEscape() bypassed for Javascript handlers, except in button()
{
},
),
'autoescape javascript turns off for textfield'
);
{
onclick => 'alert("===> password
field")',
},
),
'autoescape javascript turns off for password field'
);
{
rows => 10,
columns => 50,
},
),
qq{<textarea name="foo" rows="10" cols="50" onclick="alert("===> text area")">text area</textarea>},
'autoescape javascript turns off for textarea'
);
{
}
),
</select>},
'autoescape javascript turns off for popup_menu'
);
-values=>[
onclick =>
'alert("===> menu group option")',
)
],
-labels=>{
'eenie'=>'one',
'meenie'=>'two',
'minie'=>'three'
},
-default=>'meenie'
),
</optgroup>
</select>},
'autoescape javascript turns off for popup_menu #2'
);
onclick => 'alert("===> scrolling
list")',
-size=>5,
),
</select>},
'autoescape javascript turns off for scrolling list'
);
),
qq{<label><input type="checkbox" name="group_name" value="eenie" checked="checked" onclick="alert("===> checkbox group")" />eenie</label><br /> <label><input type="checkbox" name="group_name" value="meenie" onclick="alert("===> checkbox group")" />meenie</label><br /> <label><input type="checkbox" name="group_name" value="minie" onclick="alert("===> checkbox group")" />minie</label><br /> <label><input type="checkbox" name="group_name" value="moe" checked="checked" onclick="alert("===> checkbox group")" />moe</label><br />},
'autoescape javascript turns off for checkbox group'
);
onchange => 'alert("===> single checkbox
changed")',
-checked=>1,
-label=>'CLICK ME'
),
qq{<label><input type="checkbox" name="checkbox_name" value="ON" checked="checked" onchange="alert("===> single checkbox
'autoescape javascript turns off for checkbox'
);
{
rows=>2,
columns=>2,
}
),
qq{<table><tr><td><label><input type="radio" name="group_name" value="eenie" checked="checked" onclick="alert("===> radio group")" />eenie</label></td><td><label><input type="radio" name="group_name" value="minie" onclick="alert("===> radio group")" />minie</label></td></tr><tr><td><label><input type="radio" name="group_name" value="meenie" onclick="alert("===> radio group")" />meenie</label></td><td><label><input type="radio" name="group_name" value="moe" onclick="alert("===> radio group")" />moe</label></td></tr></table>},
'autoescape javascript turns off for radio group'
);
-value=>'value'
),
'autoescape javascript turns off for submit'
);
-align=>'MIDDLE'
),
qq{<input type="image" name="button_name" src="/source/URL" align="middle" onclick="alert("===> image button")" />},
'autoescape javascript turns off for image_button'
);
{
},
),
'autoescape javascript turns off for button'
);