Skip to content

Conversation

@jasonabird
Copy link

Changed to use filter_var when available so tags/strings that start with a number are still evaluated false as an int vs showing as a full int and being treated as a user id.

Currently if a tag starts with a number it is treated as a user id due to have intval casts. As filter_var was added later than MODX min requirements, added conditional logic to maintain backwards compatibility but allow proper validation in future versions.

Changed to use filter_var when available so tags/strings that start with a number are still evaluated false as an int vs showing as a full int and being treated as a user id.
@jpdevries
Copy link
Contributor

thanks for this @jasonabird

Copy link
Contributor

Choose a reason for hiding this comment

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

@jasonabird have you tested this? I believe this needs to have quotes around it?

if(function_exists('filter_var'))

Copy link
Author

Choose a reason for hiding this comment

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

I did test it on php 5.3 and 5.4 (don't remember subversion) as it was needed for a client that had the issue. I didn't test back to 5.1 though. Might not hurt to test a little more but wanted to contribute back the fix I applied that was breaking a tag.

On Jan 13, 2014, at 11:45, JP DeVries notifications@github.com wrote:

In core/components/articles/model/articles/articlescontainer.class.php:

@@ -322,7 +322,10 @@ public function getPostListingCall($placeholderPrefix = '') {
$where = array('class_key' => 'Article');
if (!empty($_REQUEST['arc_author'])) {
$userPk = $this->xpdo->sanitizeString($_REQUEST['arc_author']);

  •        if (intval($userPk) == 0) {
    
  •        if (function_exists(filter_var)) {
    
    @jasonabird have you tested this? I believe this needs to have quotes around it?

if(function_exists('filter_var'))

Reply to this email directly or view it on GitHub.

Copy link
Contributor

Choose a reason for hiding this comment

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

sounds good, i'd love to merge this but could you first wrap filter_var in quotes? even if it works as is, that param should be wrapped in single quotes
http://us1.php.net/function_exists

Added quotes for function_exists('filter_var')
@jasonabird
Copy link
Author

Looking at the docs again you are completely right. Updated the code and tested on the live site I did this for and still looks good. Thanks for your critical eye to catch that!

@jpdevries jpdevries merged commit 2edf452 into modxcms:develop Feb 4, 2014
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