Skip to content

Commit fa0fb00

Browse files
authored
Fix: security for unfiltered html cap (#6)
* fix: downgrading and upgrading multiple times should migrate * chore: updated readme * chore: dont' exclude pro in search * build: added file renaming for premium build * chore: updated readme screenshots * chore: updated plugin name to be more descriptive * chore: updated description * fix: conflict with others that use freemius activation * chore: updated readme * chore: updated readme * chore: version bumped to 1.3.1 * chore: updated plugin name and readme info * chore: updated tested up to * Added sanitization and security for users without unfiltered_html capability * chore: updated version number and changelog --------- Co-authored-by: bfintal@gmail.com <>
1 parent 7dcfa30 commit fa0fb00

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

src/action-types/class-action-type-update-attribute.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,33 @@ public function initialize() {
5959
$this->has_easing = false;
6060
}
6161

62+
public function is_dangerous_attribute( $attribute_name ) {
63+
if ( empty( $attribute_name ) || ! is_string( $attribute_name ) ) {
64+
return false;
65+
}
66+
67+
$attribute_name = strtolower( trim( $attribute_name ) );
68+
69+
// Event handler attributes (onclick, onerror, onload, etc.)
70+
if ( preg_match( '/^on[a-z]+/', $attribute_name ) ) {
71+
return true;
72+
}
73+
74+
// Attributes that can contain JavaScript URIs or code
75+
$dangerous_attributes = [
76+
'href',
77+
'src',
78+
'action',
79+
'formaction',
80+
// 'style', // Can contain CSS with expression() or javascript: URIs
81+
'form',
82+
'formmethod',
83+
'formtarget',
84+
];
85+
86+
return in_array( $attribute_name, $dangerous_attributes, true );
87+
}
88+
6289
public function sanitize_data_for_saving( $value ) {
6390
// Sanitize action value: ensure $value is an array and attribute/value are strings.
6491
if ( ! is_array( $value ) ) {

0 commit comments

Comments
 (0)