? ?
avatar biowan
biowan
5 Feb 2021

Steps to reproduce the issue

When a result title contains character single/double quote character ('/"), the last character of the title will be cut.

Expected result

My friend's pencil

Actual result

My friend's penci

System information (as much as possible)

The problem is from the highlight method in the script /components/com_search/views/search/view.html.php

Additional comments

I observe this problem in my current Joomla in version 3.9.24, I don't know if the problem was early.
At the moment, I remove the title highlighting to replace the ligne 165,

$result->title = $rowTitleHighLighted;
by
$result->title = $rowTitle;

avatar biowan biowan - open - 5 Feb 2021
avatar joomla-cms-bot joomla-cms-bot - labeled - 5 Feb 2021
avatar chmst chmst - change - 5 Feb 2021
Labels Added: ?
avatar chmst chmst - labeled - 5 Feb 2021
avatar infograf768
infograf768 - comment - 6 Feb 2021

In fact it comes from

public static function remove_accents($str)
{
$str = JLanguageTransliterate::utf8_latin_to_ascii($str);
// @TODO: remove other prefixes as well?
return preg_replace("/[\"'^]([a-z])/ui", '\1', $str);
}

This takes off the single quote.
If we change to
return preg_replace("/[\"^]([a-z])/ui", '\1', $str);

it should work.

Please test.

@joomla/cms-maintainers
Any undesired consequences to that change?

avatar biowan
biowan - comment - 8 Feb 2021

Hi,

Thank you for the reply.
I tested, it's work fine for single quote. So I have the same problem with the double quote. So I changed the line :

return preg_replace("/([a-z])/ui", '\1', $str);

?

Thank you and have a nice day.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/32319.

avatar richard67
richard67 - comment - 8 Feb 2021

I tested, it's work fine for single quote. So I have the same problem with the double quote. So I changed the line :

return preg_replace("/([a-z])/ui", '\1', $str);

Then it seems to me the preg_replace is not needed at all. Or am I missing something? @infograf768 What do you think?

avatar biowan
biowan - comment - 8 Feb 2021

?
@richard67 I think you are right. I didn't read all the line.
So I replace all the line and it works fine :
return $str ;

avatar richard67
richard67 - comment - 8 Feb 2021

The question is if that is right and desired. I have no idea.

avatar biowan
biowan - comment - 8 Feb 2021

Just know that the method call remove_accents($str), It must remove accent characters, but I've never used ui in regex yet.

avatar infograf768
infograf768 - comment - 8 Feb 2021

u is for unicode dependent
i is for ignore case

avatar infograf768
infograf768 - comment - 9 Feb 2021

Also,

$str = JLanguageTransliterate::utf8_latin_to_ascii($str);
is the part that takes off accents from the latin1 and latin2 strings

avatar richard67
richard67 - comment - 9 Feb 2021

So what do we need the regex for? If we remove single and double quotes from the pattern, it will remain return preg_replace("/[^]([a-z])/ui", '\1', $str);, i.e. strip off any ^. Would that be right and sufficient?

avatar richard67
richard67 - comment - 9 Feb 2021

But then the ^ should be escaped, i.e. preg_replace("/[^]([a-z])/ui", '\1', $str);. Or was that meant to be the beginning of the string? Then it should be preg_replace("/^([a-z])/ui", '\1', $str);, but then the preg_replace is useless, or not?

avatar saumyahada
saumyahada - comment - 10 Feb 2021

Hey! I am just beginning to work on open source can you guide me please?

avatar drmenzelit
drmenzelit - comment - 10 Feb 2021

@saumyahada welcome to Joomla and thank you for trying to contribute to open source.
First thing: github is the place to share code, create issues (when something doesn't work as expected) and pull requests (the solution to the bug), but it is not the place to ask support questions. You can start reading the Joomla documentation (https://docs.joomla.org) and you can use the forum to ask questions (https://forum.joomla.org).

If you are a student wanting to apply to GSoC, you should contact the team (https://docs.joomla.org/GSoC_2021)

avatar richard67
richard67 - comment - 12 Mar 2021

Closing as having a pull request. Please test #32639 . Thanks in advance.

avatar richard67 richard67 - change - 12 Mar 2021
Status New Closed
Closed_Date 0000-00-00 00:00:00 2021-03-12 09:16:47
Closed_By richard67
Labels Added: ?
Removed: ?
avatar richard67 richard67 - close - 12 Mar 2021

Add a Comment

Login with GitHub to post a comment