Add support for custom version#47
Open
groenroos wants to merge 2 commits into
Open
Conversation
| add_action('wp_enqueue_script', 'load_jquery'); | ||
| add_action('plugins_loaded', 'rg4wp_checkUser'); | ||
|
|
||
| function rg4wp_version(): string { |
There was a problem hiding this comment.
Could we add a defensive (string) cast on the constant value?
define() accepts any scalar, so someone writing define('RAYGUN_VERSION', 1.0) or define('RAYGUN_VERSION', 2) would probably trigger a TypeError here.
Suggested change:
function rg4wp_version(): string {
static $version = null;
if ($version === null) {
$version = defined('RAYGUN_VERSION') ? (string) RAYGUN_VERSION : get_bloginfo('version');
}
return $version;
}| </script> | ||
| <script type="text/javascript"> | ||
| rg4js("apiKey", "%s"); | ||
| rg4js("setVersion", "%s"); |
There was a problem hiding this comment.
Is this a potential XSS together with its usage further down around lines 80ish?
You could instead do:
$script .= 'rg4js("setVersion", ' . wp_json_encode(rg4wp_version()) . ');' . "\n";
|
|
||
| $script .= '</script>'; | ||
| printf($script, get_option('rg4wp_apikey'), get_bloginfo('version')); | ||
| printf($script, get_option('rg4wp_apikey'), rg4wp_version()); |
There was a problem hiding this comment.
See comment above for context
If you append it to the script code after encoding it, then this line would become:
printf($script, get_option('rg4wp_apikey'));
TheRealAgentK
left a comment
There was a problem hiding this comment.
Thx for the PR @groenroos - added a few suggestions for hardening it a bit.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
RAYGUN_VERSIONglobal constant for overriding the default version (WP Core version)