Hi,
In the Route66Rule class, where the regex pattern is generated, it is currently generated in this way:
$this->regex = '/' . addcslashes(preg_replace('/{(.*?)}/', '(.*?)', $this->pattern), '/') . '$/';
So, a K2 rule such us:
"{categoryAlias}/{itemDate}/{itemId}-{itemAlias}"
generates this pattern:
"/(.*?)\/(.*?)\/(.*?)-(.*?)$/"
Please, note that "." matches any character except newline (by default) (https://www.php.net/manual/en/regexp.reference.meta.php), including /.
We are finding cases where itemId is matching "item/99999", so itemId (a number) has "item/" as prefix. To give you a case, the current K2 URL is:
"/prensa/2019-05-02/14284-dia-del-periodista-comienza-la-recepcion-de-trabajos-para-el-concurso-anual"
But, the site has to handle the old URL:
"/secciones/prensa/item/14284-dia-del-periodista-comienza-la-recepcion-de-trabajos-para-el-concurso-anual"
This case is tricky since the site has a category (menu) with alias "prensa" and a username "prensa".
In any case, a better Rule expression generator is:
$this->regex = '/' . addcslashes(preg_replace('/{(.*?)}/', '([a-z0-9\-]*?)', $this->pattern), '/') . '$/';
I'm sure that this restricted pattern is going to be better in many aspects (though it doesn't take into account Unicode Aliases) ... please, confirm if it's safe to apply this workaround to solve the case, or if there is a better solution for the case.
Thanks
In the Route66Rule class, where the regex pattern is generated, it is currently generated in this way:
$this->regex = '/' . addcslashes(preg_replace('/{(.*?)}/', '(.*?)', $this->pattern), '/') . '$/';
So, a K2 rule such us:
"{categoryAlias}/{itemDate}/{itemId}-{itemAlias}"
generates this pattern:
"/(.*?)\/(.*?)\/(.*?)-(.*?)$/"
Please, note that "." matches any character except newline (by default) (https://www.php.net/manual/en/regexp.reference.meta.php), including /.
We are finding cases where itemId is matching "item/99999", so itemId (a number) has "item/" as prefix. To give you a case, the current K2 URL is:
"/prensa/2019-05-02/14284-dia-del-periodista-comienza-la-recepcion-de-trabajos-para-el-concurso-anual"
But, the site has to handle the old URL:
"/secciones/prensa/item/14284-dia-del-periodista-comienza-la-recepcion-de-trabajos-para-el-concurso-anual"
This case is tricky since the site has a category (menu) with alias "prensa" and a username "prensa".
In any case, a better Rule expression generator is:
$this->regex = '/' . addcslashes(preg_replace('/{(.*?)}/', '([a-z0-9\-]*?)', $this->pattern), '/') . '$/';
I'm sure that this restricted pattern is going to be better in many aspects (though it doesn't take into account Unicode Aliases) ... please, confirm if it's safe to apply this workaround to solve the case, or if there is a better solution for the case.
Thanks