Posted in site bugs
6022
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
174
This Month
639
This Year
729

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
The mind must be given relaxation; it will arise better and keener after resting. As rich fields must not be forced-for their productiveness, the have no rest, will quickly exhaust them constantlabor will break the vigor of the mind, but if it is released and relaxed a little while, it will recover its powers
Seneca
Random CSS Property

:user-valid (:-moz-ui-valid)

The :user-valid CSS pseudo-class represents any validated form element whose value validates correctly based on its validation constraints. However, unlike :valid it only matches once the user has interacted with it.
:user-valid css reference