[xwiki-devs] Encoding problem of UTF-8 wiki, especially with non-english URL
This is the second time I ask this question, because maybe last time I didn't describe it clearly. I hope someone can help me on this. I have created a utf-8 wiki and set Chinese as the default langauage. I met 3 main encoding problems: 1. When I created a link with Chinese name in a page also named in Chinese. I found that the ULR of the link was like" /xwiki/bin/edit/Main/%E6%B5%8B%E8%AF%951?parent=Main.测试&editor=wysiwyg", the main part is UTF-8 encoded, but the parent param is in original Chinese encoding, means two endcodings for one URL. The consequence was that when I clicked the link to edit the new page, the parent link is ill-formated, and could not find the correct parent. I checked this forum, and found that someone had met it before, but it was supposed to be resolved, see http://www.nabble.com/Non-ascii-characters-in-doc-names%2C-need-advices-for-... This problem only in IE6 and IE7, in firefox it's OK, because in firefox only one encoding in the URL. I have tried both xwiki 1.2 and 1.3, same problem. 2. When I use export function, all the pages and spaces with Chinese name are ill-named in the xar pack. 3. On the logs in CMD window of XWiki, all the Chinese words can not display correctly. Please someone help me to fix the problems, many thanks. -- View this message in context: http://www.nabble.com/Encoding-problem-of-UTF-8-wiki%2C-especially-with-non-... Sent from the XWiki- Dev mailing list archive at Nabble.com.
After checked again, I think this may be a bug when xwiki render the document. And it had appeared in earlier version.It is the same problem with http://www.nabble.com/Non-ascii-characters-in-doc-names%2C-need-advices-for-... But in earlier version it had been fixed. In new version, because the rendering architecture changed, it appeared again. I checked com.xpn.xwiki.render.XWikiWikiBaseRenderer, and found this function public static void internalLink(StringBuffer output, String start, String web, String topic, String link, String anchor, boolean doLink, XWikiContext context, Util util) { // kill spaces and Wikify page name (ManpreetSingh - 15 Sep 2000) topic = util.substitute("s/^\\s*//", topic); topic = util.substitute("s/\\s*$//", topic); topic = util.substitute("s/^(.)/\\U$1/", topic); topic = util.substitute("s/\\s([a-zA-Z0-9])/\\U$1/g", topic); // Add <nop> before WikiWord inside text to prevent double links link = util.substitute("s/(\\s)([A-Z]+[a-z]+[A-Z])/$1<nop>$2/go", link); // Parent Document XWikiDocument parentdoc = (XWikiDocument) context.get("doc"); XWiki xwiki = context.getWiki(); XWikiDocument doc; try { doc = xwiki.getDocument(web, topic, context); } catch (XWikiException e) { doc = new XWikiDocument(); doc.setName(topic); doc.setSpace(web); } output.append(start); if (!doc.isNew()) { output.append(" \""); "); output.append(link); output.append(" "); } else if (doLink) { output.append(""); output.append(link); output.append(" \""); ? "); } else { output.append(link); } } see lines output.append(doc.getURL("edit", context)); output.append("?parent="); output.append(parentdoc.getFullName()); The doc.getURL function internally use URLEncode to encod the main part of teh URL, but URLEncode function doesn't been applied to the parent param. And this cause two encodings in one URL. I also think that other encoding problems is soemthing related with this one. Since I have only start XWiki for less than 2 months and I have few knowledge about the XWiki source, so maybe I'm wrong. But I hope someone can help me , because this problem is very critical to my wiki. -- View this message in context: http://www.nabble.com/Encoding-problem-of-UTF-8-wiki%2C-especially-with-non-... Sent from the XWiki- Dev mailing list archive at Nabble.com.
After test today, I belived this is a bug and I filed a JIRA issue http://jira.xwiki.org/jira/browse/XWIKI-2297 What I do now is to modify the com.xpn.xwiki.render.XWikiRadeoxRenderEngine.java and replace the class file. in function 'public void appendCreateLink(StringBuffer buffer, String name, String view)' do following changes String querystring = null; String parentencoded = null; XWikiDocument currentdoc = context.getDoc(); if (currentdoc!=null) { try { parentencoded=URLEncoder.encode(currentdoc.getFullName()); } catch (Exception e) { parentencoded=currentdoc.getFullName(); } querystring = "parent=" + parentencoded; } LiDan wrote:
This is the second time I ask this question, because maybe last time I didn't describe it clearly. I hope someone can help me on this.
I have created a utf-8 wiki and set Chinese as the default langauage. I met 3 main encoding problems:
1. When I created a link with Chinese name in a page also named in Chinese. I found that the ULR of the link was like" /xwiki/bin/edit/Main/%E6%B5%8B%E8%AF%951?parent=Main.测试&editor=wysiwyg", the main part is UTF-8 encoded, but the parent param is in original Chinese encoding, means two endcodings for one URL. The consequence was that when I clicked the link to edit the new page, the parent link is ill-formated, and could not find the correct parent. I checked this forum, and found that someone had met it before, but it was supposed to be resolved, see http://www.nabble.com/Non-ascii-characters-in-doc-names%2C-need-advices-for-... This problem only in IE6 and IE7, in firefox it's OK, because in firefox only one encoding in the URL. I have tried both xwiki 1.2 and 1.3, same problem.
2. When I use export function, all the pages and spaces with Chinese name are ill-named in the xar pack.
3. On the logs in CMD window of XWiki, all the Chinese words can not display correctly.
Please someone help me to fix the problems, many thanks.
-- View this message in context: http://www.nabble.com/Encoding-problem-of-UTF-8-wiki%2C-especially-with-non-... Sent from the XWiki- Dev mailing list archive at Nabble.com.
Hi, Does the xwiki work well with the Chinese URI after you mended the appendCreateLink code? I think I have a solution to this problem. I use tomcat 6.0 ,MySQL 5.0 and XE 1.3.1 I configurate the xwiki to UTF-8 env, following this page http://platform.xwiki.org/xwiki/bin/view/AdminGuide/Encoding However, I add URIEncoding="UTF-8" in $tomcat_home/conf/server.conf, which I forgot last time. Then it works. I can add a link with Chinese name in a page also named in Chinese correctly. The search in Chinese works too. On Thu, Apr 10, 2008 at 5:00 AM, LiDan <[email protected]> wrote:
After test today, I belived this is a bug and I filed a JIRA issue http://jira.xwiki.org/jira/browse/XWIKI-2297 What I do now is to modify the com.xpn.xwiki.render.XWikiRadeoxRenderEngine.java and replace the class file. in function 'public void appendCreateLink(StringBuffer buffer, String name, String view)' do following changes
String querystring = null; String parentencoded = null; XWikiDocument currentdoc = context.getDoc(); if (currentdoc!=null) { try {
parentencoded=URLEncoder.encode(currentdoc.getFullName()); } catch (Exception e) { parentencoded=currentdoc.getFullName(); } querystring = "parent=" + parentencoded;
}
LiDan wrote:
This is the second time I ask this question, because maybe last time I didn't describe it clearly. I hope someone can help me on this.
I have created a utf-8 wiki and set Chinese as the default langauage. I met 3 main encoding problems:
1. When I created a link with Chinese name in a page also named in Chinese. I found that the ULR of the link was like" /xwiki/bin/edit/Main/%E6%B5%8B%E8%AF%951?parent=Main.测试&editor=wysiwyg", the main part is UTF-8 encoded, but the parent param is in original Chinese encoding, means two endcodings for one URL. The consequence was that when I clicked the link to edit the new page, the parent link is ill-formated, and could not find the correct parent. I checked this forum, and found that someone had met it before, but it was supposed to be resolved, see http://www.nabble.com/Non-ascii-characters-in-doc-names%2C-need-advices-for-... This problem only in IE6 and IE7, in firefox it's OK, because in firefox only one encoding in the URL. I have tried both xwiki 1.2 and 1.3, same problem.
2. When I use export function, all the pages and spaces with Chinese name are ill-named in the xar pack.
3. On the logs in CMD window of XWiki, all the Chinese words can not display correctly.
Please someone help me to fix the problems, many thanks.
-- View this message in context: http://www.nabble.com/Encoding-problem-of-UTF-8-wiki%2C-especially-with-non-...
Sent from the XWiki- Dev mailing list archive at Nabble.com.
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
-- 祝好! 盼回复! Wang Ning
participants (2)
-
LiDan -
Wang Ning