WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. senyoraangelica
    Member
    Posted 10 months 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=">
            </form>
        </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">
    </form>

    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.
    https://github.com/pods-framework/pods/issues/1620
    Also, this doesn't appear to be a conflict from another theme or plugin.

  2. senyoraangelica
    Member
    Posted 10 months 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
    Member
    Posted 10 months ago #

    let there be bump.

Reply

You must log in to post.

About this Topic