Support » Plugin: Simple Calendar - Google Calendar Plugin » Search queries with quotes don't work

  • Resolved justdave

    (@justdave)


    I am trying to set up a calendar which shows only events matching a specific phrase.

    The event names all have the format of “Troop 3 – Chapter 4” for example, and I want to show only the events for Chapter 3. Putting just Chapter 3 into the search box (as you’d expect) matches my example above, because both “Chapter” and “3” occur in it. In Google Calendar, I can put “Chapter 3” with quotes around it and it successfully matches only the events that have “Chapter 3” as a contiguous phrase. However, when I put quotes around it in Simple Calendar, it fails to match anything at all. The documentation even points this out and suggests using quotes around the phrase to match an entire phrase, so I’m guessing this is supposed to actually work.

    https://wordpress.org/plugins/google-calendar-events/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter justdave

    (@justdave)

    I was poking at the code and found/fixed the bug.

    Line 111 of includes/feeds/google.php does this to load the query out of the database:

    $this->google_search_query = esc_attr( get_post_meta( $this->post_id, '_google_events_search_query', true ) );

    which turns my "Chapter 3" into "Chapter 3"

    This is good if you’re outputting it in an HTML document, except you’re not. It’s going into the query string of a URL.

    Line 349 then does this:

    $args['q'] = rawurlencode( $this->google_search_query );

    Which turns the "Chapter 3" into %26quot;Chapter 3%26quot; when it should actually be getting sent as %22Chapter 3%22

    If I remove the esc_attr() from line 111 it finds exactly what it’s supposed to.

    This appears to be the only place $this->google_search_query is used so this should be safe. I don’t see it outputting to html anywhere except in the admin section, and that’s properly escaping it separately.

    Thank you, I need that fix too 🙂

    Plugin Contributor Nick Young

    (@nickyoung87)

    Hey thanks for finding this. I will mark this on our GH to fix or you can start a Pull Request for it if you would like: https://github.com/moonstonemedia/Simple-Calendar/pulls

    Thanks again!

    Thread Starter justdave

    (@justdave)

    Done. No prob

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Search queries with quotes don't work’ is closed to new replies.