Репозиторий ALT Linux backports/2.4
Последнее обновление: 9 июля 2008 | Пакетов: 497 | Посещений: 1573890
 поиск   регистрация   авторизация 
 
Группа :: Система/Серверы
Пакет: squid

 Главная   Изменения   Спек   Патчи   Загрузить   Bugs and FR 

Патч: squid-2.5.STABLE10-ftp_title-2.patch


Index: squid/src/ftp.c
diff -c squid/src/ftp.c:1.316.2.25 squid/src/ftp.c:1.316.2.28
*** squid/src/ftp.c:1.316.2.25	Fri Mar 25 19:50:53 2005
--- squid/src/ftp.c	Wed Jun 22 04:42:34 2005
***************
*** 365,379 ****
      wordlist *w;
      char *dirup;
      int i, j, k;
!     char *title;
      storeBuffer(e);
      storeAppendPrintf(e, "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n");
      storeAppendPrintf(e, "<!-- HTML listing generated by Squid %s -->\n",
  	version_string);
      storeAppendPrintf(e, "<!-- %s -->\n", mkrfc1123(squid_curtime));
      storeAppendPrintf(e, "<HTML><HEAD><TITLE>\n");
!     storeAppendPrintf(e, "FTP Directory: %s\n",
! 	html_quote(strBuf(ftpState->title_url)));
      storeAppendPrintf(e, "</TITLE>\n");
      storeAppendPrintf(e, "<STYLE type=\"text/css\"><!--BODY{background-color:#ffffff;font-family:verdana,sans-serif}--></STYLE>\n");
      if (ftpState->flags.use_base)
--- 365,383 ----
      wordlist *w;
      char *dirup;
      int i, j, k;
!     const char *title = strBuf(ftpState->title_url);
      storeBuffer(e);
      storeAppendPrintf(e, "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n");
      storeAppendPrintf(e, "<!-- HTML listing generated by Squid %s -->\n",
  	version_string);
      storeAppendPrintf(e, "<!-- %s -->\n", mkrfc1123(squid_curtime));
      storeAppendPrintf(e, "<HTML><HEAD><TITLE>\n");
!     {
! 	char *t = xstrdup(title);
! 	rfc1738_unescape(t);
! 	storeAppendPrintf(e, "FTP Directory: %s\n", html_quote(t));
! 	xfree(t);
!     }
      storeAppendPrintf(e, "</TITLE>\n");
      storeAppendPrintf(e, "<STYLE type=\"text/css\"><!--BODY{background-color:#ffffff;font-family:verdana,sans-serif}--></STYLE>\n");
      if (ftpState->flags.use_base)
***************
*** 392,418 ****
      storeAppendPrintf(e, "FTP Directory: ");
      /* "ftp://" == 6 characters */
      assert(strLen(ftpState->title_url) >= 6);
!     title = html_quote(strBuf(ftpState->title_url));
      for (i = 6, j = 0; title[i]; j = i) {
  	storeAppendPrintf(e, "<A HREF=\"");
  	i += strcspn(&title[i], "/");
  	if (title[i] == '/')
  	    i++;
- 	for (k = 0; k < i; k++)
- 	    storeAppendPrintf(e, "%c", title[k]);
- 	storeAppendPrintf(e, "\">");
- 	for (k = j; k < i - 1; k++)
- 	    storeAppendPrintf(e, "%c", title[k]);
- 	if (strBuf(ftpState->title_url)[k] != '/')
- 	    storeAppendPrintf(e, "%c", title[k++]);
- 	storeAppendPrintf(e, "</A>");
- 	if (k < i)
- 	    storeAppendPrintf(e, "%c", title[k++]);
  	if (i == j) {
  	    /* Error guard, or "assert" */
  	    storeAppendPrintf(e, "ERROR: Failed to parse URL: %s\n",
! 		html_quote(strBuf(ftpState->title_url)));
! 	    debug(9, 0) ("Failed to parse URL: %s\n", strBuf(ftpState->title_url));
  	    break;
  	}
      }
--- 396,424 ----
      storeAppendPrintf(e, "FTP Directory: ");
      /* "ftp://" == 6 characters */
      assert(strLen(ftpState->title_url) >= 6);
!     k = 6 + strcspn(&title[6], "/");
      for (i = 6, j = 0; title[i]; j = i) {
  	storeAppendPrintf(e, "<A HREF=\"");
  	i += strcspn(&title[i], "/");
+ 	if (i > j) {
+ 	    char *url = xstrdup(title);
+ 	    url[i] = '\0';
+ 	    storeAppendPrintf(e, "%s", html_quote(url + k));
+ 	    storeAppendPrintf(e, "/");
+ 	    storeAppendPrintf(e, "\">");
+ 	    rfc1738_unescape(url + j);
+ 	    storeAppendPrintf(e, "%s", html_quote(url + j));
+ 	    safe_free(url);
+ 	    storeAppendPrintf(e, "</A>");
+ 	}
+ 	storeAppendPrintf(e, "/");
  	if (title[i] == '/')
  	    i++;
  	if (i == j) {
  	    /* Error guard, or "assert" */
  	    storeAppendPrintf(e, "ERROR: Failed to parse URL: %s\n",
! 		html_quote(title));
! 	    debug(9, 0) ("Failed to parse URL: %s\n", title);
  	    break;
  	}
      }
***************
*** 1059,1070 ****
  	strCat(ftpState->title_url, xitoa(request->port));
      }
      strCat(ftpState->title_url, strBuf(request->urlpath));
-     {
- 	char *t = xstrdup(strBuf(ftpState->title_url));
- 	rfc1738_unescape(t);
- 	stringReset(&ftpState->title_url, t);
- 	xfree(t);
-     }
  
      stringReset(&ftpState->base_href, "ftp://");
      if (strcmp(ftpState->user, "anonymous")) {
--- 1065,1070 ----
 
design & coding: Vladimir Lettiev aka crux © 2004-2005