Ultimate SEO Urls

Advanced search result bug - Ultimate SEO Urls

Advanced search result bug

by artfulweb » Mon Jul 11, 2022 3:53 pm

Hi there,
Just found a bug when doing searches with two words, eg. red apples. The results are correct but when you click on it you get an error page : ERR_TOO_MANY_REDIRECTS. This does not happen in single search words like "apples". Any ideas, please?
artfulweb
VIP Member
VIP Member
Posts: 119
Joined: Thu Oct 29, 2020 12:34 pm
Contact:

Re: Advanced search result bug

by Piernas » Tue Jul 12, 2022 4:50 pm

I didn't test search - it seems that search is adding a keywords parameter. Seems that the addon doesn't like the '+' sign inside the query so I¡ll have to see where the error is happening. I'll come back when fixed.
Piernas
Posts: 96
Joined: Thu Mar 11, 2021 2:16 am
Contact:

Re: Advanced search result bug

by Piernas » Wed Jul 13, 2022 7:29 am

I think this will fix the issue: changing usu_cleanse function in includes/apps/ultimate_seo_urls/includes/usu_general_functions.php to:

Code: Select all

  function usu_cleanse( $value ) {
    // replace the spaces with + signs and remove spaces at the end
    $value = htmlspecialchars_decode (rtrim($value));
    $value = preg_replace( '/ /', '/+/', $value );
    return preg_replace( '@[^a-z0-9_\%{}[]]@i', '', $value );
  }
The reason was Phoenix search was generating urls with an space inside the search parameter (URL should not contain a literal space but a '+' character) and USU didn't understand it. With the above it will ensure the parameters do not contain any space and will allow characters like % [ ] { } that are often used by addons.

I'll later look at the rewrite part also to ensure spaces are passed correctly when generating URL.

Please let me know if it works for you.
Piernas
Posts: 96
Joined: Thu Mar 11, 2021 2:16 am
Contact:

Re: Advanced search result bug

by Piernas » Wed Jul 13, 2022 7:44 am

Ok there must be something else in the code. I found some products doesn't add to cart when added from a search with spaces because the form is still keeping spaces inside. I'll keep testing.
Piernas
Posts: 96
Joined: Thu Mar 11, 2021 2:16 am
Contact:

Re: Advanced search result bug

by artfulweb » Wed Jul 13, 2022 10:56 am

Piernas wrote:Ok there must be something else in the code. I found some products doesn't add to cart when added from a search with spaces because the form is still keeping spaces inside. I'll keep testing.
Thanks for your efforts, I will wait for the fix.
artfulweb
VIP Member
VIP Member
Posts: 119
Joined: Thu Oct 29, 2020 12:34 pm
Contact:

Re: Advanced search result bug

by Piernas » Wed Jul 13, 2022 6:58 pm

After testing usu_cleanse function I've decided to completely remove it. This was used to allow only alphanumerical characters into HTML queries. That blocks the usage of {} for shopping cart links or spaces for search results and would clean up any other character used for querystrings in any addon. I am not sure what was the reason the original author wrote it but I think it's pretty useless.

Can you please change usu_cleanse function in includes/apps/ultimate_seo_urls/includes/usu_general_functions.php to:

Code: Select all

  function usu_cleanse( $value ) {
    return $value; //deprecated function as several addons and stock search results uses special characters
  }
And let me know if you find any issue?
Piernas
Posts: 96
Joined: Thu Mar 11, 2021 2:16 am
Contact:

Re: Advanced search result bug

by artfulweb » Wed Jul 13, 2022 9:37 pm

Piernas wrote:After testing usu_cleanse function I've decided to completely remove it. This was used to allow only alphanumerical characters into HTML queries. That blocks the usage of {} for shopping cart links or spaces for search results and would clean up any other character used for querystrings in any addon. I am not sure what was the reason the original author wrote it but I think it's pretty useless.

Can you please change usu_cleanse function in includes/apps/ultimate_seo_urls/includes/usu_general_functions.php to:

Code: Select all

  function usu_cleanse( $value ) {
    return $value; //deprecated function as several addons and stock search results uses special characters
  }
And let me know if you find any issue?

Looks good. The search function now works and there does not seem to be a problem with the cart either. Thanks so much!
artfulweb
VIP Member
VIP Member
Posts: 119
Joined: Thu Oct 29, 2020 12:34 pm
Contact:

Re: Advanced search result bug

by Denzel » Tue Aug 02, 2022 5:00 pm

I found something else with the same behavior. When I search for something with a german umlaut like 'ä','ö','ü', the results are displayed, but when I click on an article, the "too many redirects" error message also appears. I've already tried the above changes, unfortunately without success.

Phoenix 1.0.8.16 USU 3.0.5 PHP 8
Denzel
VIP Member
VIP Member
Posts: 98
Joined: Sat Oct 31, 2020 7:22 pm
Contact:

Re: Advanced search result bug

by Denzel » Tue Aug 02, 2022 5:07 pm

By the way: The above fix also removes a problem which occured with google ads. When clicking on an ad, the "too many redirects" error message also appeared. But not anymore :)
Denzel
VIP Member
VIP Member
Posts: 98
Joined: Sat Oct 31, 2020 7:22 pm
Contact:

Re: Advanced search result bug

by Piernas » Tue Aug 02, 2022 5:57 pm

Denzel wrote:I found something else with the same behavior. When I search for something with a german umlaut like 'ä','ö','ü', the results are displayed, but when I click on an article, the "too many redirects" error message also appears. I've already tried the above changes, unfortunately without success.

Phoenix 1.0.8.16 USU 3.0.5 PHP 8
I'll look ai it, I hadn't tried special characters yet.

In the meanwhile, can you test if the same link works without the "keywords" querysting?
Piernas
Posts: 96
Joined: Thu Mar 11, 2021 2:16 am
Contact: