-
Notifications
You must be signed in to change notification settings - Fork 0
Fix: security for unfiltered html cap #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
dd8db2f
b50e53b
f4e4cd0
fa36321
504b5a6
7af089b
639fe26
c69d4c7
5b3af2b
5e7aacd
0c397bd
0c29260
c1746b5
6577283
94f0c19
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -52,6 +52,11 @@ public function initialize() { | |
|
|
||
| // return parent::initilize_action( $action, $animation_data ); | ||
| // } | ||
|
|
||
| public function sanitize_data_for_saving( $value ) { | ||
| $value['color'] = $this->sanitize_style_value( $value['color'] ); | ||
| return $value; | ||
| } | ||
|
Comment on lines
+56
to
+59
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Guard As with the CSS rule action, the use of A small defensive tweak keeps behavior while hardening against bad input: - public function sanitize_data_for_saving( $value ) {
- $value['color'] = $this->sanitize_style_value( $value['color'] );
- return $value;
- }
+ public function sanitize_data_for_saving( $value ) {
+ if ( is_array( $value ) && isset( $value['color'] ) ) {
+ $value['color'] = $this->sanitize_style_value( $value['color'] );
+ }
+
+ return $value;
+ }This matches the defensive style used in other action types while preserving the new sanitization. 🤖 Prompt for AI Agents |
||
| } | ||
|
|
||
| interact_add_action_type( 'backgroundColor', 'Interact_Action_Type_Background_Color' ); | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -33,6 +33,11 @@ public function initialize() { | |||||||||||||||||||||
|
|
||||||||||||||||||||||
| $this->has_dynamic = false; | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| public function sanitize_data_for_saving( $value ) { | ||||||||||||||||||||||
| $value['image'] = $this->sanitize_style_value( $value['image'] ); | ||||||||||||||||||||||
| return $value; | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
Comment on lines
+37
to
+40
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add null checks before accessing array keys. Lines 38 accesses Apply this diff for consistency with other sanitization methods: public function sanitize_data_for_saving( $value ) {
- $value['image'] = $this->sanitize_style_value( $value['image'] );
+ if ( is_array( $value ) && isset( $value['image'] ) ) {
+ $value['image'] = $this->sanitize_style_value( $value['image'] );
+ }
return $value;
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| interact_add_action_type( 'backgroundImage', 'Interact_Action_Type_Background_Image' ); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -40,6 +40,11 @@ public function initialize() { | |
| ], | ||
| ]; | ||
| } | ||
|
|
||
| public function sanitize_data_for_saving( $value ) { | ||
| $value['value'] = $this->sanitize_style_value( $value['value'] ); | ||
| return $value; | ||
| } | ||
|
Comment on lines
+44
to
+47
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add defensive checks before accessing The sanitization logic is good, but accessing To match the more defensive pattern used in other action types (e.g., text color, redirect), you can guard the access: - public function sanitize_data_for_saving( $value ) {
- $value['value'] = $this->sanitize_style_value( $value['value'] );
- return $value;
- }
+ public function sanitize_data_for_saving( $value ) {
+ if ( is_array( $value ) && isset( $value['value'] ) ) {
+ $value['value'] = $this->sanitize_style_value( $value['value'] );
+ }
+
+ return $value;
+ }This keeps the sanitization behavior while avoiding runtime warnings on unexpected input shapes. 🤖 Prompt for AI Agents |
||
| } | ||
|
|
||
| interact_add_action_type( 'cssRule', 'Interact_Action_Type_Css_Rule' ); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -63,6 +63,37 @@ public function initialize() { | |
|
|
||
| $this->has_dynamic = false; | ||
| } | ||
|
|
||
| public function sanitize_data_for_saving( $value ) { | ||
| if ( is_array( $value ) && isset( $value['rotate'] ) ) { | ||
| if ( is_numeric( $value['rotate'] ) ) { | ||
| $value['rotate'] = $value['rotate'] + 0; | ||
| } else { | ||
| $value['rotate'] = null; | ||
| } | ||
| } | ||
|
|
||
| if ( is_array( $value ) && isset( $value['transformOrigin'] ) ) { | ||
| $allowed_transform_origins = [ | ||
| 'center', | ||
| 'top', | ||
| 'right', | ||
| 'bottom', | ||
| 'left', | ||
| 'top left', | ||
| 'top right', | ||
| 'bottom left', | ||
| 'bottom right', | ||
| 'custom', | ||
| ]; | ||
| if ( ! in_array( $value['transformOrigin'], $allowed_transform_origins, true ) ) { | ||
| $value['transformOrigin'] = 'center'; | ||
| } | ||
| } | ||
|
|
||
| $value['customTransformOrigin'] = $this->sanitize_style_value( $value['customTransformOrigin'] ); | ||
| return $value; | ||
| } | ||
|
Comment on lines
+67
to
+96
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add null check before accessing array key. Line 94 accesses Apply this diff to add the check: if ( is_array( $value ) && isset( $value['transformOrigin'] ) ) {
$allowed_transform_origins = [
'center',
'top',
'right',
'bottom',
'left',
'top left',
'top right',
'bottom left',
'bottom right',
'custom',
];
if ( ! in_array( $value['transformOrigin'], $allowed_transform_origins, true ) ) {
$value['transformOrigin'] = 'center';
}
}
- $value['customTransformOrigin'] = $this->sanitize_style_value( $value['customTransformOrigin'] );
+ if ( isset( $value['customTransformOrigin'] ) ) {
+ $value['customTransformOrigin'] = $this->sanitize_style_value( $value['customTransformOrigin'] );
+ }
return $value;🤖 Prompt for AI Agents |
||
| } | ||
|
|
||
| interact_add_action_type( 'rotate', 'Interact_Action_Type_Rotate' ); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: gambitph/Interactions
Length of output: 5119
🏁 Script executed:
Repository: gambitph/Interactions
Length of output: 5171
Rename from
interactions.phptoplugin.phpbreaks existing premium upgrade path and Freemius trackingThe rename creates a breaking change for existing premium installations. Previous premium releases have the plugin activated as
interactions/interactions.php, but after this change, the main file becomesinteractions/plugin.php.Freemius tracks the plugin by
plugin_basename($this->plugin_main_file), which will now returninteractions/plugin.phpinstead ofinteractions/interactions.php. On upgrade, WordPress will have both files present—the old active file and the new main file—but Freemius and the plugin action links hook will reference the new basename, causing:Either add a migration strategy (deactivate and reactivate the plugin during upgrade), document this as a breaking change requiring manual re-activation, or reconsider if renaming to
plugin.phpis necessary for the premium build.🤖 Prompt for AI Agents