Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2009307
  • 博文数量: 369
  • 博客积分: 10093
  • 博客等级: 上将
  • 技术积分: 4271
  • 用 户 组: 普通用户
  • 注册时间: 2005-03-21 00:59
文章分类

全部博文(369)

文章存档

2013年(1)

2011年(2)

2010年(10)

2009年(16)

2008年(33)

2007年(146)

2006年(160)

2005年(1)

分类:

2006-03-03 00:34:24

Squid代理ftp站时,如果ftp站点内有中文目录或者文件,显示为乱码。还有第一行的导航栏为%xy的不可读模式,简单的patch了一下,基本解决了以上的问题。补丁请见附件(因为附件暂时不知道如何使用,用源码给出),在rpm包管理的操作系统中如何使用此补丁,请参照前文!
diff -urN squid-2.5.STABLE6.orig/lib/html_quote.c squid-2.5.STABLE6/lib/html_quote.c
--- squid-2.5.STABLE6.orig/lib/html_quote.c     2001-10-18 03:46:43.000000000 +0800
+++ squid-2.5.STABLE6/lib/html_quote.c  2006-03-02 22:32:37.000000000 +0800
@@ -114,7 +114,8 @@
         * sure all 8-bit characters are encoded to protect from buggy
         * clients
         */
-       if (!escape && (ch <= 0x1F || ch >= 0x7f) && ch != '\n' && ch != '\r' && ch != '\t') {
+       if (!escape && (ch <= 0x1F || ch == 0x7f || ch > 0xfd)
+                       && ch != '\n' && ch != '\r' && ch != '\t') {
            static char dec_encoded[7];
            snprintf(dec_encoded, sizeof dec_encoded, "&#%3d;", (int) ch);
            escape = dec_encoded;
diff -urN squid-2.5.STABLE6.orig/src/ftp.c squid-2.5.STABLE6/src/ftp.c
--- squid-2.5.STABLE6.orig/src/ftp.c    2004-06-01 07:14:37.000000000 +0800
+++ squid-2.5.STABLE6/src/ftp.c 2006-03-02 22:26:42.000000000 +0800
@@ -1027,6 +1027,7 @@
 static void
 ftpBuildTitleUrl(FtpStateData * ftpState)
 {
+       char *tmp;
     request_t *request = ftpState->request;

     stringReset(&ftpState->title_url, "ftp://");
@@ -1039,7 +1040,10 @@
        strCat(ftpState->title_url, ":");
        strCat(ftpState->title_url, xitoa(request->port));
     }
-    strCat(ftpState->title_url, strBuf(request->urlpath));
+       tmp = xmalloc(strlen(strBuf(request->urlpath)) + 1);
+       strcpy(tmp, strBuf(request->urlpath));
+       rfc1738_unescape(tmp);
+    strCat(ftpState->title_url, tmp);

     stringReset(&ftpState->base_href, "ftp://");
     if (strcmp(ftpState->user, "anonymous")) {
@@ -1055,8 +1059,9 @@
        strCat(ftpState->base_href, ":");
        strCat(ftpState->base_href, xitoa(request->port));
     }
-    strCat(ftpState->base_href, strBuf(request->urlpath));
+    strCat(ftpState->base_href, tmp);
     strCat(ftpState->base_href, "/");
+       xfree(tmp);
 }

 CBDATA_TYPE(FtpStateData);


阅读(1674) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~