Skip to content

Update/simple notifier to check - #171

Closed
amerk-sitecrafting wants to merge 7 commits into
mainfrom
update/simple-notifier-to-check
Closed

amerk-sitecrafting wants to merge 7 commits into
mainfrom
update/simple-notifier-to-check

Conversation

@amerk-sitecrafting

Copy link
Copy Markdown
Contributor

Ticket: #
247
249

Issue

Currently Conifer performs an "unsafe" redirect when viewing the edit-comments.php page in the admin center.

Conifer's SimpleNotifier constructor does not validate that $to is either a single email, comma separated list of emails, or array of emails.

Solution

Update wp_redirect -> wp_safe_redirect

Add validation to the Simple Notifier constructor, and throw an \InvalidArgumentException if validation fails

Impact

If any site is extending the SimpleNotifier and attempt to pass in an invalid array, bad stuff will happen. But, more specifically it will throw an exception, which needs to be handled in that code.

Usage Changes

None

Testing

All tests pass after this update. The tests will also run in the pipeline.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Aug 20, 2026 •

Copy link
Copy Markdown

Deploying conifer-plugin with  Cloudflare Pages  Cloudflare Pages

Latest commit: 7543849
Status: ✅  Deploy successful!
Preview URL: https://f5ef0db0.conifer-plugin.pages.dev
Branch Preview URL: https://update-simple-notifier-to-ch.conifer-plugin.pages.dev

View logs

@rhendrickson-sc rhendrickson-sc left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks good! I just left some questions on it, but nothing that's a blocker.

Comment thread lib/Conifer/Notifier/SimpleNotifier.php Outdated
throw new \InvalidArgumentException(self::DEFAULT_EXCEPTION_MESSAGE);
}

if (gettype($to) === 'string') {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question, why use gettype instead of is_string?

Docs: https://www.php.net/manual/en/function.is-string.php

Comment thread lib/Conifer/Notifier/SimpleNotifier.php Outdated

// If we have reached this point, we have an array of some sort, so we need to validate all of the emails in the array.
// We will still check the type for sanity
if (gettype($toCopy) === 'array') {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same question as above, why use gettype instead of is_array?

Docs: https://www.php.net/manual/en/function.is-array.php

Comment thread lib/Conifer/Notifier/SimpleNotifier.php Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could also type $to as string|array to make it more consistent with the other updates in this file.

@rhendrickson-sc rhendrickson-sc left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! I'm just curious though if we want to make a v2 branch and merge this into that instead, so we can prep for a v2 without "dirty-ing" the main branch with v2 code before we officially launch it.

@amerk-sitecrafting

Copy link
Copy Markdown
Contributor Author

Looks good! I'm just curious though if we want to make a v2 branch and merge this into that instead, so we can prep for a v2 without "dirty-ing" the main branch with v2 code before we officially launch it.

Way ahead of you! I have not updated the target for this branch (which would require remaking the entire PR), but I do have an upgrade/v2 branch that this will be merged into

@amerk-sitecrafting

Copy link
Copy Markdown
Contributor Author

This PR is approved and merged into the v2 branch, so I am closing this PR out

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants