Recent Topics

1 Dec 05, 2008 13:36    

In 2.4.5 to which I just upgraded a few minutes ago, an URL ending in dash '-' or colon ':' (in addition to the original semi-colon ';') is considered to point to a tag page.

This, however, introduces URL resolution conflicts with old urltitles for single posts created automatically. If the original post title was too large, b2evo would trim it to 40(?) characters. But if the last of the 40 characters was a space, b2evo doesn't ignore this space and therefore the urltitle ends up with a trailing dash.

Take for instance [url=http://liberal-venezolano.net/blog/2008/08/13/bush-dijo-no-a-nuevas-armas-para-ataque-]this post of mine[/url] whose title was very long:

Bush dijo no a nuevas armas para ataque israelí contra Irán

This title has 60 characters. The resultant URLtitle is

bush-dijo-no-a-nuevas-armas-para-ataque-

which has 40 characters. But you see, the last (40th) character of the title was a space (after "ataque"). So we end up with a trailing dash and a conflict with URL resolution. When trying to access this post, you're sent to a non-existent tag page.

Since I don't know how many posts (around 2000 in total for my blog) I have with trailing dashes in their URLtitles, I simply edited line 162 in inc/_main_blog.inc.php so that now it reads:

			if( $last_char == ':'|| $last_char == ';' )

instead of

			if( $last_char == '-' || $last_char == ':'|| $last_char == ';' )

An alternative for the future would be to trim trailing whitespace in the urltitle generation function to avoid this.

2 Dec 06, 2008 19:19

You could try this query to remove all the trailing "-" chars from your URL titles:

UPDATE evo_items__item SET post_urltitle = TRIM( TRAILING '-' FROM post_urltitle );

Of course make sure you have a database backup before executing the query...
The disadvantage of this solution is that some old URLs might not work anymore.

//edit: Fixed in HEAD and v-2-4. Thanks for reporting!

3 Dec 23, 2008 08:01

:D
Thanks for that Austriaco
I suddenly found that I could not access some older posts with the hyphen at the end.

4 Feb 23, 2009 18:39

My blog is updated to 2.4.6, yet I am having this issue as well.

I have been upgrading via the version-to-version patches so maybe something was missed. Could someone direct me to which file contains the fix for the issue so I could compare versions and/or apply the fix?

I would prefer not to update the DB titles to prevent breaking of some links. ;)

Thanks for any help!

5 Mar 02, 2009 06:54

What's the best solution for this, then? I have the same problem.

6 Mar 02, 2009 15:41

@nelsonguirado

I ended up applying the patch noted above (a simple one really). I just wasn't sure that was the "official" fix and I was still having the issue in the latest version of b2evo.

I've been using the upgrade "patches", so I don't know if perhaps the official fix was left out of those?

7 Mar 17, 2009 02:58

I'm doing the official fix right now.

8 Mar 17, 2009 15:27

It's still broken on 2.4.6 ;)

9 Mar 17, 2009 16:46

if( ( $last_char == '-' && ( strlen( $path_string ) != 40 ) ) || $last_char == ':' || $last_char == ';' )

10 Mar 17, 2009 21:37

Hum... I was really thinking about change the way that we detect the things on urls ;)

11 Mar 18, 2009 02:38

The Afwas suggestion would work,except in the case where you have a tag slug with 39 chars, ans uses dashes ;)

12 Mar 23, 2009 13:52

This has been fixed in HEAD.


Form is loading...