cubecart / v6

CubeCart Version 6
https://cubecart.com
72 stars 59 forks source link

Code Check: Bounce to URL #3449

Closed bhsmither closed 9 months ago

bhsmither commented 9 months ago

For example, Catalogue class near line 2100:

httpredir('?_a=product&product_id='.$this->_category_products[0]['product_id']);

which goes to functions.inc.php near line 686:

$rewrite = $GLOBALS['seo']->rewriteUrls(sprintf('href="%s"', $destination));

which goes to SEO class near line 619:

$search = '#(href|action)=["\'](.*/)?[\w]+.[a-z]+\?_a\=([\w]+)\&(amp;)?([\w]+)\=([\w\-\_]+)([^"\']*)["\']#Si';

The regex pattern breaks down to:

The above breaks down as:
1: (href|action) the word 'href' or 'action'
 : =["']         literally = followed by a quote or apostrophe
2: (.*/)?        zero or more of characters ending in a slash, that all may or may not exist
 : [\w\-\_]+     one or more word-type characters, dash, or underscore
 : .             a period (technically any one character)
 : [a-z]+        one more letters a-z
 : \?_a\=        literally ?_a=
3: ([\w]+)       one or more word-type characters -- this will be the action verb as listed in the generatePath() function
 : \&            literally &
4: (amp;)?       literally amp; that all may or may not exist
5: ([\w]+)       one or more word-type characters -- this will be the key related to the target of the action verb
 : \=            literally =
6: ([\w\-\_]+)   one or more word-type characters, dash, or underscore -- this will be the value for the key related to the target of the action verb
7: ([^"\']*)     zero or more characters that is not a quote or apostrophe -- the rest of the querystring
 : ["']          a quote or apostrophe

   action="anything/anything/an-th_ng.sufx?_a=product&product_id=40001&the_rest"
   (  1 )  (        2       )                 (  3  )4(   5    ) ( 6 )(   7   )

Note that the httpredir argument does not have anything for that which is required to exist after capturing group 2. That thing would typically be index.php. It could also be search and the like.

Without this content, the URL does not get rewritten.

abrookbanks commented 9 months ago

Pretty happy with this now. Any bugs should show themselves quickly.