Posted in site bugs
5867
4:04 am, July 10, 2021
 

weird search results being recorded

i noticed some weird search results being recorded like this:

the search function should only be recording a result if it finds a result, so this should not be added unless it can actually find this text, which i doubt it. 

Some annoying robot is adding this i think. 

page: search.page.php

PHP

if($search_value > "") {
    $page_content .= $class->list_all(
        $start = $start_val,
        $max = $page_step,
        "search", 
        $template_file_name,
        $search_term = $search_value
    );
}

i think the issue is with the search link text being added from the url. it does not validate if the text exists on the page before adding it, so need a check on there before adding it. 

e.g: https://kruxor.com/view/code/DPkzR/weird-search-results-being-recorded/search_text:::weird%20search%20results%20being%20recorded 

I have only allowed the characters on searches, so this should fix the random text issues now.

PHP

$search_text = preg_replace("/[^A-Za-z0-9 ]/", '', $search_text);

see if this solves the problem

View Statistics
This Week
118
This Month
663
This Year
574

No Items Found.

Add Comment
Type in a Nick Name here
 
Search Code
Search Code by entering your search text above.
Welcome

This is my test area for webdev. I keep a collection of code here, mostly for my reference. Also if i find a good link, i usually add it here and then forget about it. more...

Subscribe to weekly updates about things i have added to the site or thought interesting during the last week.

You could also follow me on twitter or not... does anyone even use twitter anymore?

If you found something useful or like my work, you can buy me a coffee here. Mmm Coffee. ☕

❤️👩‍💻🎮

🪦 2000 - 16 Oct 2022 - Boots
Random Quote
1. Show your work to the world instead of keeping in your head💆. 2. Do the work consistently👌 3. Respect your work🥰 4. Don't postpone your work 5. Make mistakes 🔥🔥🔥
Unknown
Random CSS Property

<color>

The <color> CSS data type represents a color. A <color> may also include an alpha-channel transparency value, indicating how the color should composite with its background.
hsl() css reference