前幾天有篇文章在標題中出現 -- 字元, 結果在 Firefox 看這篇文章時, 在標題前會出現一個多餘的 //--> (也可能是 -->, 看你的 template 怎麼寫的), 而這個問題在 IE 中是不會出現的.
這會是 Firefox 的 bug 嗎? 上網問了一下, 有人給了這個 html 註解的定義網頁 (http://www.htmlhelp.org/reference/wilbur/misc/comment.html"), 上面有提到註解的定義. 其中, 有說明當使用 -- 當註解之後, 不應該有 -- 存在於註解之中. 所以, 我想 Firefox 這樣子處理, 並不能算是 bug 吧.
既然這不能算是 Firefox 的問題, 所以... 就要想法子由 LifeType 來解決. 會出現這個問題的原因是因為文章的標題會有 -- 出現, 而 LifeType 的 postTrackbackLink() 在輸出資料於註解的時候, 也會把文章標題列在其中, 所以, 我們只要想辦法在這個輸出的地方, 把文章標題有出現 - 的, 都改成 \-, 來避免這個問題. (PS. 會不會造成這個運作有問題呢? 我想應該不會吧, 頂多看到的 topic 不太正確, 並不會影響 trackback 的 link, 而且 \- 在 browser 上頭, 看到的應該也是 - 吧.)
這個 patch 可以由這兒抓取: http://www.teatime.com.tw/~tommy/mypatch/lifetype_postTrackbackLink_topic.patch
diff -Nur class.orig/net/customrequestgenerator.class.php class/net/customrequestgenerator.class.php
--- class.orig/net/customrequestgenerator.class.php 2006-06-16 08:25:45.680792558 +0800
+++ class/net/customrequestgenerator.class.php 2006-06-16 08:36:23.160057155 +0800
@@ -283,11 +283,13 @@
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">';
- $trackbackLink = $this->getTrackbackUrl()."?id=".$post->getId();
+ $trackbackLink = str_replace('-', '%2D', $this->getTrackbackUrl()."?id=".$post->getId());
+ $postLink = str_replace('-', '%2D', $this->postLink($post));
+ $topic = str_replace('-', '\-', $post->getTopic());
$rdfBody = "<rdf:Description
- rdf:about=\"".$this->postLink($post)."\"
- dc:identifier=\"".$this->postLink($post)."\"
- dc:title=\"".$post->getTopic()."\"
+ rdf:about=\"".$postLink."\"
+ dc:identifier=\"".$postLink."\"
+ dc:title=\"".$topic."\"
trackback:ping=\"".$trackbackLink."\"/>";
$rdfFooter = "</rdf:RDF>";
diff -Nur class.orig/net/modrewriterequestgenerator.class.php class/net/modrewriterequestgenerator.class.php
--- class.orig/net/modrewriterequestgenerator.class.php 2006-06-16 08:26:08.656621134 +0800
+++ class/net/modrewriterequestgenerator.class.php 2006-06-16 08:36:55.351819113 +0800
@@ -224,12 +224,13 @@
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">';
- $trackbackLink = $this->getTrackbackUrl()."?id=".$post->getId();
-
+ $trackbackLink = str_replace('-', '%2D', $this->getTrackbackUrl()."?id=".$post->getId());
+ $postLink = str_replace('-', '%2D', $this->postLink($post));
+ $topic = str_replace('-', '\-', $post->getTopic());
$rdfBody = "<rdf:Description
- rdf:about=\"".$this->postLink($post)."\"
- dc:identifier=\"".$this->postLink($post)."\"
- dc:title=\"".$post->getTopic()."\"
+ rdf:about=\"".$postLink."\"
+ dc:identifier=\"".$postLink."\"
+ dc:title=\"".$topic."\"
trackback:ping=\"".$trackbackLink."\"/>";
$rdfFooter = "</rdf:RDF>";
diff -Nur class.orig/net/prettyrequestgenerator.class.php class/net/prettyrequestgenerator.class.php
--- class.orig/net/prettyrequestgenerator.class.php 2006-06-16 08:26:18.596546991 +0800
+++ class/net/prettyrequestgenerator.class.php 2006-06-16 08:37:11.207701904 +0800
@@ -245,11 +245,13 @@
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">';
- $trackbackLink = $this->getTrackbackUrl()."?id=".$post->getId();
+ $trackbackLink = str_replace('-', '%2D', $this->getTrackbackUrl()."?id=".$post->getId());
+ $postLink = str_replace('-', '%2D', $this->postLink($post));
+ $topic = str_replace('-', '\-', $post->getTopic());
$rdfBody = "<rdf:Description
- rdf:about=\"".$this->postLink($post)."\"
- dc:identifier=\"".$this->postLink($post)."\"
- dc:title=\"".$post->getTopic()."\"
+ rdf:about=\"".$postLink."\"
+ dc:identifier=\"".$postLink."\"
+ dc:title=\"".$topic."\"
trackback:ping=\"".$trackbackLink."\"/>";
$rdfFooter = "</rdf:RDF>";
diff -Nur class.orig/net/rawrequestgenerator.class.php class/net/rawrequestgenerator.class.php
--- class.orig/net/rawrequestgenerator.class.php 2006-06-16 08:26:28.660471933 +0800
+++ class/net/rawrequestgenerator.class.php 2006-06-16 08:37:23.439611499 +0800
@@ -260,11 +260,13 @@
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">';
- $trackbackLink = $this->getTrackbackUrl()."?id=".$post->getId();
+ $trackbackLink = str_replace('-', '%2D', $this->getTrackbackUrl()."?id=".$post->getId());
+ $postLink = str_replace('-', '%2D', $this->postLink($post));
+ $topic = str_replace('-', '\-', $post->getTopic());
$rdfBody = "<rdf:Description
- rdf:about=\"".$this->postLink($post)."\"
- dc:identifier=\"".$this->postLink($post)."\"
- dc:title=\"".$post->getTopic()."\"
+ rdf:about=\"".$postLink."\"
+ dc:identifier=\"".$postLink."\"
+ dc:title=\"".$topic."\"
trackback:ping=\"".$trackbackLink."\"/>";
$rdfFooter = "</rdf:RDF>";
http://bugs.lifetype.net/view.php?id=956
2006/6/16 修正:
1. str_replace() 參數順序寫錯. :-(
2. 如果有用自訂的 url, 則 url 也要把 '-' 改成 '%2D'