WordPress.org

Support

Support » Plugins and Hacks » Fedmich's Facebook Open Graph Meta » [Resolved] Links to YouTube videos causing trash output

[Resolved] Links to YouTube videos causing trash output

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author fedmich

    @fedmich

    Hello nkinkade,
    Thank you for reporting that. I appreciate you wanting to help and even sending patch of your codes.

    rather than doing this ([a-zA-Z0-9]+)@i
    you could do this ([a-z0-9]+)@i
    because i, (…)@i here means ignore case

    but still your code will not match this youtube link
    http://www.youtube.com/watch?v=M7lc1UVf-VE

    because it has “hyphen”, sometimes videoId has hyphens and other non-alphanumeric characters.

    I’m running unit tests and a bunch of html code combinations and I think they all still work fine.
    Could you send me the actual HTML Codes in your post that you encountered this?

    Thanks mate

    Thanks for the quick reply. When this URL is in $pcontent:

    http://www.youtube.com/watch?v=Q5mHPo2yDG8

    The output of your plugin is:

    http://natha.nkinka.de/misc/fedmich_facebook_open_graph_meta.html

    It’s because the (.*) at the end of the regex on line 101 is greedily matching all the way to the end of the <a/> element, and so is the (.*) on line 107.

    I suppose you could fix this by changing the regex on line 107 to (.*?), but is there a specific the whole conditional block between lines 106-111 exists? It seems to be that you could eliminate everything between lines 100-111 by just changing the regex on line 96 to more thoroughly isolate the video ID. I don’t know what characters can possibly show up in a YouTube video ID, but I would imagine that it certainly can’t include a quote character, so it would seem that changing the regex on 95 to the following would suffice to eliminate lines 100-111:

    ‘@(www\.|)youtube.com/watch\?v=(.*?)”@i’

    Thanks!

    Nathan

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Resolved] Links to YouTube videos causing trash output’ is closed to new replies.
Skip to toolbar