Support » Plugin: Shadowbox JS » [Plugin: Shadowbox JS] bug in "Push To Title"

  • 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=".*?")[^>]+?>%';

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Matt Martz


    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.

    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.

    Plugin Author Matt Martz


    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 (\’|”)

    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.


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

    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.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘[Plugin: Shadowbox JS] bug in "Push To Title"’ is closed to new replies.