WordPress.org

Ready to get started?Download WordPress

Forums

SoundCloud Shortcode
[resolved] Disastrous update 2.2.3 breaks encoding of posts (16 posts)

  1. archon810
    Member
    Posted 2 years ago #

    The new update 2.2.3 ended up screwing up content on the site because it doesn't handle decoding/encoding right and is invasive as it hooks into every post update. Here's what happened to a normal html entity for a space character (& nbsp ;) http://i.imgur.com/VzJGa.jpg after saving a post after installing SC2.2.3: http://i.imgur.com/Zp1DU.jpg

    Because it makes the content invalid, the effect cascaded down to other plugins which broke the post display altogether. The worst part was that I updated 6-7 plugins altogether and had to revert them one by one until tracing it to this plugin.

    Upon examining the code changes, I found this:

    add_filter("content_save_pre", "soundcloud_reverse_shortcode");
    
    function soundcloud_reverse_shortcode($content) {
      return preg_replace_callback('/<iframe(?:(?!>).)*>.*?<\/iframe>/i', 'soundcloud_reverse_shortcode_callback', stripslashes(html_entity_decode($content)));
    }

    and so on. I'm not entirely positive where exactly the problem is located because I was scrambling to revert it, but I'd guess it's a whole bunch of html_entity_decodings or using DOMDocument, or something else.

    Part of the point is, a plugin that should be limited to embeds of occasional shortcodes shouldn't hook into every save (and end up mangling them big time). It looks like the logic is trying to permanently convert iframes to shortcodes, but forcing this behavior by default is entirely unnecessary.

    http://wordpress.org/extend/plugins/soundcloud-shortcode/

  2. Ralph83
    Member
    Posted 2 years ago #

  3. por_
    Member
    Plugin Author

    Posted 2 years ago #

    I see. I disabled it for now so an update should fix it (version 2.2.5). Not sure what’s causing it as I didn’t dive deeper into the WordPress code that handles this, but I won’t reenable before knowing what went wrong.

    Sorry about that and thanks for reporting.

  4. archon810
    Member
    Posted 2 years ago #

    Glad to see some fast action here as well as another report confirming the same problem within 3 minutes of mine.

  5. Ralph83
    Member
    Posted 2 years ago #

    UPDATE: okay, just read 2.2.5 has disabled the buggy code as well.

    Removed my own temporary fix from this post.

  6. por_
    Member
    Plugin Author

    Posted 2 years ago #

    You seem to be right that DOMDocument is causing it. I might have to resort to using a regex anyway. The reason why this bit of code is in here is because you can’t copy-paste an <iframe> in your post on WordPress.com. The reverse shortcode would fix that.

  7. por_
    Member
    Plugin Author

    Posted 2 years ago #

    @ralph83 Yes I left the code in for now, but uncommented registering the filter. I would still like to keep the reverse shortcode logic in, but only after testing it better.

  8. archon810
    Member
    Posted 2 years ago #

    @por_ I created this a few years back and have been reliably using it ever since on a production site with 6mln pageviews: http://beerpla.net/projects/smartdomdocument-a-smarter-php-domdocument-class.

    I just compared your code and mine and turns out this problem is well known and I already resolved it in SmartDOMDocument. I even noted the garbled output in the post, but of course after these years forgot all about it.

    Check it out.

  9. por_
    Member
    Plugin Author

    Posted 2 years ago #

    @archon810 I’ll have a look at it, thanks.

  10. Ralph83
    Member
    Posted 2 years ago #

    @por_ yup, my own fix uncommented the line within function soundcloud_reverse_shortcode, but going to stick with yours.

    Thank you for looking into this so fast!

    @archon810 6mln pageviews?! Wow!

  11. archon810
    Member
    Posted 2 years ago #

    @Ralph83 Yup, http://www.androidpolice.com. It's more than 6mln actually (monthly).

  12. Ralph83
    Member
    Posted 2 years ago #

    @archon810 I hope you don't mind, but I emailed you via the contact page on beerpla. I was hoping that maybe you can give me some tips re getting so many pageviews :) Anyway, didn't want to go too off topic here, hence the email.

  13. archon810
    Member
    Posted 2 years ago #

    @Ralph83 hmm, didn't get any email, looks like my contact form is borked. I can't offer any specific tips - you just have to have persistence, a good subject, decent design, and lots of luck.

  14. Ralph83
    Member
    Posted 2 years ago #

    @archon810 Thanks!

  15. archon810
    Member
    Posted 1 year ago #

    So was this ever fixed properly?

  16. Ralph83
    Member
    Posted 1 year ago #

    I don't think so. Haven't seen a new update since then.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.