Help - Search - Members - Calendar
Full Version: MT 2.66 and XHTML bug
Movable Type Community Forum > Other Product Discussion > Bugs and Odd Behavior
distler
MT 2.66 turns URLs in comments into redirects. Unfortunately, the existing code fails miserably if you are serving your pages as application/xhtml+xml. Here's a patch to fix it (see also my blog entry).
arvind
what exaclty are u meant to do with this patch where does it go ?
distler
From the commandline, in the main MT directory,
CODE
patch < 2.66.patch

or you could apply the changes by hand, by editing lib/MT/App/Comments.pm.

Of course, if you are not sending your pages as application/xhtml+xml, the original code will work fine.
75th Trombone
Another problem: The redirect URLs are invalid themselves. They use straight ampersands instead of &amp; entities.

Which script writes these URLs, so it can be fixed?

SFT
Jeroen Sangers
Have a look at lib/MT/Template/Context.pm, around line 1189. I changed this line, and my site produces valid HTML again.

See also MT update breaks validation
distler
Yeah, I "revised" my patch above to include both fixes in the same patch file. (I previously had them in two separate files.)
TweezerMan
Six Apart has released an update (MT 2.661) that fixes the invalid XHTML in the redirect URL.
distler
But no the other issue.

So, back to my original patch (to lib/MT/App/Comments.pm alone).
distler
Alas, 2.661 still does not produce valid XHTML in the Comment-Preview window. The problem is that a comment being previewed does not yet have a CommentID.

This fixes the problem:
CODE
--- lib/MT/Template/Context.pm.orig     Thu Jan 15 14:36:13 2004
+++ lib/MT/Template/Context.pm  Thu Jan 15 17:33:55 2004
@@ -1184,7 +1184,7 @@
       my $cgi_path = MT::ConfigMgr->instance->CGIPath;
       $cgi_path =~ s#([^/])$#$1/#;
       my $comment_script = MT::ConfigMgr->instance->CommentScript;
-       return sprintf(qq(<a target="_blank" href="%s%s?__mode=red&id=%d">%s</a>),
+       if($c->id){
+         return sprintf(qq(<a href="%s%s?__mode=red&id=%d">%s</a>),
                      $cgi_path, $comment_script, $c->id, $name);
+       } else {
+         return sprintf(qq(<a href="%s">%s</a>), $c->url, $name);
+        }
    } elsif ($show_email && $c->email) {
        my $email = remove_html($c->email);


I folded this into the patch file mentioned above (which now applies to 2.661).
cobra libre
Thanks for coming up with a fix so quickly, Jacques.

One tiny thing: The patch you posted for 2.661 on this page needs to be changed so that the ampersand in the line
CODE
return sprintf(qq(<a href="%s%s?__mode=red&id=%d">%s</a>),

is escaped.
distler
Thanks for the catch. I edited the comment appropriately.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2008 Invision Power Services, Inc.