Recent Topics

1 Jun 14, 2008 17:33    

Hi, all.

When trackback using multi-byte character is sent, the end of excerpt line often includes invalid character.
Therefore, trackback fails. :(
# I use Japanese language.

To fix this problem, I rewrote substr() to mb_strcut().


*** inc/comments/_trackback.funcs.php.orig	Sat Jun 14 23:51:12 2008
--- inc/comments/_trackback.funcs.php	Sun Jun 15 00:17:23 2008
***************
*** 42,48 ****
  {
  	global $Messages;
  
! 	$excerpt = (strlen(strip_tags($content)) > 255) ? substr(strip_tags($content), 0, 252).'...' : strip_tags($content);
  	$Messages->add( T_('Excerpt sent in trackbacks:').' '.$excerpt, 'note' );
  	$trackback_urls = split('( )+', $post_trackbacks,10);		// fplanque: ;
  	foreach($trackback_urls as $tb_url)
--- 42,48 ----
  {
  	global $Messages;
  
! 	$excerpt = (strlen(strip_tags($content)) > 255) ? mb_strcut(strip_tags($content), 0, 252, $evo_charset).'...' : strip_tags($content);
  	$Messages->add( T_('Excerpt sent in trackbacks:').' '.$excerpt, 'note' );
  	$trackback_urls = split('( )+', $post_trackbacks,10);		// fplanque: ;
  	foreach($trackback_urls as $tb_url)

There may be some problems, I want anyone to test this fix.
I think that all other substr() also should be rewritten to mb_strcut().

Thanks.

2 Jun 17, 2008 18:25

Sorry. My fix doesn't work.
The following is corrected one. The "global" lacked.


*** inc/comments/_trackback.funcs.php.orig	Sat Jun 14 23:51:12 2008
--- inc/comments/_trackback.funcs.php	Wed Jun 18 01:04:01 2008
***************
*** 41,48 ****
  function trackbacks( $post_trackbacks, $content, $post_title, $post_ID )
  {
  	global $Messages;
  
! 	$excerpt = (strlen(strip_tags($content)) > 255) ? substr(strip_tags($content), 0, 252).'...' : strip_tags($content);
  	$Messages->add( T_('Excerpt sent in trackbacks:').' '.$excerpt, 'note' );
  	$trackback_urls = split('( )+', $post_trackbacks,10);		// fplanque: ;
  	foreach($trackback_urls as $tb_url)
--- 41,49 ----
  function trackbacks( $post_trackbacks, $content, $post_title, $post_ID )
  {
  	global $Messages;
+ 	global $evo_charset;
  
! 	$excerpt = (strlen(strip_tags($content)) > 255) ? mb_strcut(strip_tags($content), 0, 252, $evo_charset).'...' : strip_tags($content);
  	$Messages->add( T_('Excerpt sent in trackbacks:').' '.$excerpt, 'note' );
  	$trackback_urls = split('( )+', $post_trackbacks,10);		// fplanque: ;
  	foreach($trackback_urls as $tb_url)


Should it take care that A is null or not ... ?
I want someone to write more suitable code...

Thanks.

3 Jun 17, 2008 18:36

Hi cress_cc. Thanks for the proposed solution! I do believe this happened in a different thread recently, but it might be a slightly different flavor of the same 'general' problem.

However I would suggest to you that most people will not understand what your code above means. It is some sort of "diff" file correct? But no one can actually just use the code as you've shown it because it is not made for that? May I suggest you show us "find this section in this file" then show us "now replace it with these lines instead" so that people can copy/paste directly from the forum into a file editor? Also if you are willing to, a link to a downloadable version of "after editing" is very helpful for even more people. Many users of course are not comfortable editing files.


Form is loading...