歡迎光臨, 訪客. 請先 登入註冊一個帳號.
四月 20, 2024, 10:44:09 上午
19595 文章 在 3865 主題 由 4580 會員
最新註冊會員: aa123aa1
LifeType 中文開發論壇  |  開發  |  核心補強  |  修正 Lifetype 文章標題有 -- 出現時, 會顯示不正常的情形 « 上篇主題 下篇主題 »
頁: [1]
作者 主題: 修正 Lifetype 文章標題有 -- 出現時, 會顯示不正常的情形  (閱讀 8037 次)
twu2
初級會員
**
文章: 61



檢視個人資料 個人網站
« 於: 六月 14, 2006, 01:58:27 下午 »

前幾天有篇文章在標題中出現 -- 字元, 結果在 Firefox 看這篇文章時, 在標題前會出現一個多餘的 //--> (也可能是 -->, 看你的 template 怎麼寫的), 而這個問題在 IE 中是不會出現的.

這會是 Firefox 的 bug 嗎? 上網問了一下, 有人給了這個 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'
« 最後編輯時間: 六月 16, 2006, 07:41:18 上午 由 twu2 » 已記錄

頁: [1]
LifeType 中文開發論壇  |  開發  |  核心補強  |  修正 Lifetype 文章標題有 -- 出現時, 會顯示不正常的情形 « 上篇主題 下篇主題 »
    前往: