WordPress.org

Ready to get started?Download WordPress

Forums

Shadowbox JS
bug in "Push To Title" (7 posts)

  1. arcticcoconut
    Member
    Posted 3 years ago #

    I found a bug in shadowbox-title-push.php.
    If I set an outside URL for a picture to link to, the picture disappears.
    I hunted it to a bad quotemark in these two lines in the PHP file:

    $anchor_title_pattern = '%<a[^>]+title=[\'"].*?[\'"][^>]+?>%';
    $img_title_pattern = '%<img[^>]+(title=[\'"].*?[\'"])[^>]+?>%';

    I changed it thus, and now it works:

    $anchor_title_pattern = '%<a [^>]+title=".*?"[^>]+?>%';
    $img_title_pattern = '%<img [^>]+(title=".*?")[^>]+?>%';

    http://wordpress.org/extend/plugins/shadowbox-js/

  2. Matt Martz
    Member
    Plugin Author

    Posted 3 years ago #

    The bug is known, but removing the single quotes breaks this for people who use single quotes instead of double, just causing another bug. The better solution is to convert single quotes within the title to html entities. I have not yet looked into better handling of this.

  3. fattchris
    Member
    Posted 3 years ago #

    I may be incorrect (as I am just now looking at this issue), but the pattern is a regular expression, and the portion:

    [\'"]

    is saying to look explicitly for a single quote NEXT to a double quote. If you add a pipe:

    [\'|"]

    if should look for a single quote OR a double quote. Let me know if that fixes it.

  4. Matt Martz
    Member
    Plugin Author

    Posted 3 years ago #

    You are indeed reading it incorrectly. [] defines a character class, in this case it looks for exactly 1 of any of the characters inside of the character class, in this case a single or double quote.

    [\'"] is basically the same as (\'|")

  5. fattchris
    Member
    Posted 3 years ago #

    Ah, you are indeed correct! I guess I would need to know more about the bug itself to know why the single quote is causing issue to begin with.

    Thanks!

  6. arcticcoconut
    Member
    Posted 3 years ago #

    OK, so my luck is stronger than my PHP-fu. I'm probably better off that way, after all.

  7. arcticcoconut
    Member
    Posted 3 years ago #

    fwiw/fyi: When the code got parsed, for title=, the open quote was double and the close quote was single (or maybe the other way around), causing the HTML to break for the img.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic