- Posts: 175
COMMUNITY FORUM
Tags: spaces at the beginning do not get stripped
- Oceanwatcher
-
Topic Author
- Offline
- Elite Member
Less
More
14 years 8 months ago #87672
by Oceanwatcher
Tags: spaces at the beginning do not get stripped was created by Oceanwatcher
I have been pasting in tags a couple of times and were not aware that the tag had a space at the beginning.This results in tags being sorted wrong and there is no way to fix it as the tag that is stored and shown if you try to edit it is without the space.It is especially annoying when using JoomFish as the tags in JoomFish are sorted alphabetically and it can be very difficult to find the right tag if you have a lot...
Please Log in or Create an account to join the conversation.
- David R.
-
- Offline
- Premium Member
Less
More
- Posts: 81
14 years 8 months ago #87673
by David R.
Replied by David R. on topic Tags: spaces at the beginning do not get stripped
I agree this is a bug that could be fixed very simply with a trim statement. There's no reason to allow tags to have leading or trailing spaces. I'm having to fix tags that a client has added where he put in hundreds of tags using the comma and out of habit always typed a space or two. Now I'm having to clean this up with SQL.
Please Log in or Create an account to join the conversation.
- Lefteris
-
- Offline
- Platinum Member
Less
More
- Posts: 8743
14 years 8 months ago #87674
by Lefteris
Replied by Lefteris on topic Tags: spaces at the beginning do not get stripped
Hi. Fixed at the SVN version. Thanks for reporting.
Please Log in or Create an account to join the conversation.
- David R.
-
- Offline
- Premium Member
Less
More
- Posts: 81
14 years 8 months ago #87675
by David R.
Replied by David R. on topic Tags: spaces at the beginning do not get stripped
Thanks Lefteris!
Lefteris Kavadas said:Hi. Fixed at the SVN version. Thanks for reporting.
Lefteris Kavadas said:Hi. Fixed at the SVN version. Thanks for reporting.
Please Log in or Create an account to join the conversation.
- Oceanwatcher
-
Topic Author
- Offline
- Elite Member
Less
More
- Posts: 175
14 years 8 months ago #87676
by Oceanwatcher
Replied by Oceanwatcher on topic Tags: spaces at the beginning do not get stripped
Thank you. Looking forward to the release! :-)
Now we only need to be able to add tags with hyphens. There are a lot of words that need hyphens according the correct way of spelling them in many languages, so this HAS to be in there!
Now we only need to be able to add tags with hyphens. There are a lot of words that need hyphens according the correct way of spelling them in many languages, so this HAS to be in there!
Please Log in or Create an account to join the conversation.
- David R.
-
- Offline
- Premium Member
Less
More
- Posts: 81
14 years 8 months ago #87677
by David R.
Replied by David R. on topic Tags: spaces at the beginning do not get stripped
FWIW, if people want to put in a quick hack until the official release:
Go into /administrator/components/com_k2/tables/k2tag.php
remove function check(), and replace it with this code:
function check() {
$this->name = trim($this->name);
if ($this->name == '') {
$this->setError(JText::_('Tag cannot be empty'));
return false;
}
$this->name = str_replace('-','',$this->name);
return true;
}
Notice the str_replace for the '-' is one of the reasons that hyphens get removed. Commenting that out,, and in several other places and you can save tags with hyphens. The problem is that the tags module breaks when you click on articles related to the tag with hyphen, because for some reason, when the hyphenated parameter gets passed in the url, it ultimately gets changed from:
foo-bar
to
foo:bar
I ran out of time trying to understand what is going on inside of Joomla, as this appears to be related to the JDatabase Quote() function, afaik. Since this replace for hyphens is put in a number of different places, it makes me think that the K2 guys might have seen some issue with this, or that there's some security related issue with hyphens that causes the joomla api to modify them. Or it might also be related to the controller code and joomla's use of a ':" to pack url params.
Go into /administrator/components/com_k2/tables/k2tag.php
remove function check(), and replace it with this code:
function check() {
$this->name = trim($this->name);
if ($this->name == '') {
$this->setError(JText::_('Tag cannot be empty'));
return false;
}
$this->name = str_replace('-','',$this->name);
return true;
}
Notice the str_replace for the '-' is one of the reasons that hyphens get removed. Commenting that out,, and in several other places and you can save tags with hyphens. The problem is that the tags module breaks when you click on articles related to the tag with hyphen, because for some reason, when the hyphenated parameter gets passed in the url, it ultimately gets changed from:
foo-bar
to
foo:bar
I ran out of time trying to understand what is going on inside of Joomla, as this appears to be related to the JDatabase Quote() function, afaik. Since this replace for hyphens is put in a number of different places, it makes me think that the K2 guys might have seen some issue with this, or that there's some security related issue with hyphens that causes the joomla api to modify them. Or it might also be related to the controller code and joomla's use of a ':" to pack url params.
Please Log in or Create an account to join the conversation.