The Support Forums will be in read-only mode for a scheduled maintenance window on 01 September 2016 14:00 UTC - 20:00 UTC. More information.

Backslash at the end of searchword breaks custom search form (3 posts)

  1. senyoraangelica
    Posted 3 years ago #

    Accidentally, I discovered that whenever there is a backslash at the end of a search, the page after clicking submit will return a broken search form.
    In my case, the submit button turned into a text area.

    Using google chrome's "inspect element" I saw that my search form turned into this:

    <form method="get" action="">
    <input type="hidden" name="type" value="books">
    <input type="text" name="search" value="\">        <input type=">
        </div></div></div><div id=" sidebar"="" class="sidebar widget-area"></form>

    The following code is my form. I am guessing that I need to sanitize/escape the value from the input type text? But why isn't esc_attr() working? I am very new at this. Please help. I will extremely appreciate it!

    <form action="" method="get">
    <input type="text" name="search" value="<?php echo esc_attr(stripslashes($_GET['search'])); ?>">
    <input type="submit" value="Search">
    <input type="checkbox" name="title">

    P.S. I am using this custom search form to search custom fields and display the resulting custom post types using Pods Plugin. It doesn't appear that this is a Pods plugin issue though.
    Also, this doesn't appear to be a conflict from another theme or plugin.

  2. senyoraangelica
    Posted 3 years ago #

    I am wondering if this is an isolated case or are there any other wordpress users experiencing the same? Because I don't remember encountering this issue before the wordpress update.

  3. senyoraangelica
    Posted 3 years ago #

    let there be bump.

Topic Closed

This topic has been closed to new replies.

About this Topic