WordPress.org

Ready to get started?Download WordPress

Forums

Google-hilite bug (and fix) (5 posts)

  1. Anonymous
    Unregistered
    Posted 10 years ago #

    The google-hilite plugin has a bug where an empty search string from the wordpress internal search (i.e., http://myblog.com/?s=) results in the entire URL being sent as the search string. The unescaped slashes then raise a PHP error.
    The fix: Change the preg_replace which is extracting the wordpress search from:
    $query_terms = preg_replace('/^.*s=([^&]+)&?.*$/i','$1', $referer);
    to:
    $query_terms = preg_replace('/^.*s=([^&]+)?.*$/i','$1', $referer);
    (here is the diff -u):
    --- google-hilite.php Sat Jul 17 15:08:41 2004
    +++ google-hilite-new.php Sat Jul 17 15:09:45 2004
    @@ -47,7 +47,7 @@
    break;
    }
    - $query_terms = preg_replace('/^.*s=([^&]+)&?.*$/i','$1', $referer);
    + $query_terms = preg_replace('/^.*s=([^&]+)?.*$/i','$1', $referer);
    $query_terms = preg_replace('/\'|"/', '', $query_terms);
    $query_array = preg_split ("/[\s,\+\.]+/", $query_terms);
    break;
    Thanks,
    Charlie DeTar

  2. BoM
    Member
    Posted 10 years ago #

    I have another fix for the google-hilite plugin-- if there are any '/'s in the search term, the plugin chokes and breaks the display. I inserted this at line 104 to fix it:
    $term = preg_quote($term, '/');

  3. duches77
    Member
    Posted 10 years ago #

    At the risk of sounding stupid, is this in reference to the one post return not highlighting the searched word?

  4. Ryan Boren
    WordPress Dev
    Posted 10 years ago #

    The preg_quote fix is already in CVS.

  5. duches77
    Member
    Posted 10 years ago #

    I'm assuming that it isn't in reference to one post returns...

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.