Page 10 of 12 FirstFirst ... 89101112 LastLast
Results 91 to 100 of 118

Thread: My plugin removed from WP.org extend directory

  1. #91
    Ryan's Avatar
    Ryan is offline WordPress Legend
    Join Date
    Jan 2009
    Location
    New Zealand
    Posts
    2,801

    Default

    Quote Originally Posted by andreasnrb View Post
    Hmm can the users write > then?
    They can with wp_filter_nohtml_kses(). And since using > characters in CSS is useless I'll go filter those out too.

    EDIT: I'm now using htmlspecialchars( wp_filter_nohtml_kses()) which seems to be doing a good job of stripping out all the stuff I don't want, while still allowing legit CSS to stay.

    EDIT 2: I'm using those functions on input to the database and when echo'd into the admin page and on the front-end of the site, so hopefully that covers all my bases.

    EDIT 3: Actually > and < characters are useful in CSS, so I guess I can't do that after all :( Damnit!

    EDIT 4: All Google searches I try to do on validating CSS, keep showing up information about direct CSS validation, eg: the W3C CSS validator :(
    Last edited by Ryan; 02-12-2010 at 04:33 AM.

  2. #92
    andreasnrb's Avatar
    andreasnrb is offline Kegger
    Join Date
    Jun 2009
    Posts
    595

  3. #93
    Ryan's Avatar
    Ryan is offline WordPress Legend
    Join Date
    Jan 2009
    Location
    New Zealand
    Posts
    2,801

    Default

    Quote Originally Posted by andreasnrb View Post
    > is a css selector
    Yup. I forgot about that :P I must have edited my post just before you replied.

    I now have to go back and undo it all :(

    EDIT: Fixed back the way they were :) I did add htmlspecialchars() to a bunch other stuff that needed it though so it wasn't all a waste of time thankfully :)

    EDIT 2: Dangnabbit! I was looking at the output on screen and didn't click that the > and < characters were converted to their entity form. Damnit!!!! Back to the drawing board ...
    Last edited by Ryan; 02-12-2010 at 04:57 AM.

  4. #94
    Utkarsh is offline Hello World
    Join Date
    Nov 2009
    Posts
    73

    Default

    Quote Originally Posted by Ryan View Post
    Ah, that makes sense based on it's name. The codex page just says what it strips out and it seems that the fixes for the LightSEO plugin uses it to filter out a textarea's content, which is what I'm using it for here, specifically for entering CSS code.



    No, but you can in CSS which is what I'm trying to filter.


    I think wp_filter_nohtml_kses() is what I need to use, so I'll plow ahead and use that unless anyone suggests otherwise.
    If you want to filter css, why don't you see how the plugin WordPress.com team released (custom css plugin) does it?
    Edit: This one http://wordpress.org/extend/plugins/safecss/

  5. #95
    andreasnrb's Avatar
    andreasnrb is offline Kegger
    Join Date
    Jun 2009
    Posts
    595

    Default

    Damned if you do damned if you don't =). But stripping out javascript and making sure " and ' are closed is all you need I suppose.
    EDIT
    They use CSSTidy http://csstidy.sourceforge.net/

  6. #96
    Ryan's Avatar
    Ryan is offline WordPress Legend
    Join Date
    Jan 2009
    Location
    New Zealand
    Posts
    2,801

    Default

    CSS Tidy is a little overkill. That's more for optimisation of the CSS code, rather than the just doing security checks.

    That Automattic plugin was a darn good suggestion to look at though!

    I've only had a quick flick through the code, but from what I can see, they are actually using wp_kses() and then rewriting the entities back intto their corresponding characters.
    PHP Code:
            $css str_replace'<=''&lt;='$css );
            
    // Why KSES instead of strip_tags?  Who knows?
            
    $css wp_kses_split($prev $css, array(), array());
            
    $css str_replace'&gt;''>'$css ); // kses replaces lone '>' with &gt; 

  7. #97
    andreasnrb's Avatar
    andreasnrb is offline Kegger
    Join Date
    Jun 2009
    Posts
    595

    Default

    I like the comment // Why KSES instead of strip_tags? Who knows?

  8. #98
    chipbennett's Avatar
    chipbennett is offline WordPress Legend
    Join Date
    Feb 2009
    Location
    St. Louis, MO
    Posts
    1,997

    Default

    So, can someone tell me why an un-patched version of AIOSEO Pack is still available in the repository?

    Have we been given any justification for removing Alden's plugin without notice, yet leaving AIO SEO available, even after weeks of notice of the vulnerabilities?
    WP TurnKey - Turn-Key WordPress installation and maintenance services
    WordPress user since 2005 | @chip_bennett | chipbennett.net | cbnet Plugins

  9. #99
    andreasnrb's Avatar
    andreasnrb is offline Kegger
    Join Date
    Jun 2009
    Posts
    595

  10. #100
    Otto's Avatar
    Otto is offline On The Rocks
    Join Date
    Apr 2009
    Location
    Memphis, TN
    Posts
    865

    Default

    Quote Originally Posted by Ryan View Post
    Ummm, well that's interesting ...

    That would certainly explain why there is next to no documentation whatsoever on how to use white listing.
    Yep. register_setting adds the option being registered to the whitelist. That's actually the main purpose of it. A secondary purpose is to add the sanitize callback function to it. The way this works is surprisingly simple.

    register_setting is just a wrapper around add_option_update_handler.

    add_option_update_handler adds the option to the "new_whitelist", and adds the callback to the sanitize_option_{$option_name} filter.

    In the wp-admin/option.php file, where options get processed and saved, the whitelist_options filter gets applied. This calls the option_update_filter function, which goes through that list of options added to the "new_whitelist", and adds them to the real whitelist.

    That whitelist is used, on the submit of the options page, to eliminate invalid options. Basically, it loops through the whitelisted options for the given page and only pulls those out of the $_POST array, discarding everything else.

    Oh, and sanitize_option_{$option_name} is one of the first things that gets called on any update_option. Basically, it protects your options against even internal updates.

    So, short version: If you use the Settings API properly, you don't have to screw with whitelisting and update_option and nonces and all that other crap. It's all handled for you transparently. All you have to do is to register your settings and provide the necessary callbacks to a) produce the input fields and b) validate the incoming values.

Page 10 of 12 FirstFirst ... 89101112 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •