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

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

Патч: squid-2.5.STABLE10-ftp_basehref.patch


Index: squid/src/ftp.c
diff -c squid/src/ftp.c:1.316.2.26 squid/src/ftp.c:1.316.2.27
*** squid/src/ftp.c:1.316.2.26	Tue Jun 21 16:18:19 2005
--- squid/src/ftp.c	Tue Jun 21 16:21:31 2005
***************
*** 69,74 ****
--- 69,75 ----
      unsigned int http_header_sent:1;
      unsigned int tried_nlst:1;
      unsigned int use_base:1;
+     unsigned int dir_slash:1;
      unsigned int root_dir:1;
      unsigned int no_dotdot:1;
      unsigned int html_header_sent:1;
***************
*** 87,92 ****
--- 88,94 ----
      int password_url;
      char *reply_hdr;
      int reply_hdr_state;
+     String clean_url;
      String title_url;
      String base_href;
      int conn_att;
***************
*** 96,101 ****
--- 98,104 ----
      squid_off_t size;
      wordlist *pathcomps;
      char *filepath;
+     char *dirpath;
      squid_off_t restart_offset;
      squid_off_t restarted_offset;
      int rest_att;
***************
*** 437,445 ****
      storeBuffer(e);
      storeAppendPrintf(e, "</PRE>\n");
      if (ftpState->flags.listformat_unknown && !ftpState->flags.tried_nlst) {
! 	storeAppendPrintf(e, "<A HREF=\"./;type=d\">[As plain directory]</A>\n");
      } else if (ftpState->typecode == 'D') {
! 	const char *path = ftpState->filepath ? ftpState->filepath : ".";
  	storeAppendPrintf(e, "<A HREF=\"%s/\">[As extended directory]</A>\n", html_quote(path));
      }
      storeAppendPrintf(e, "<HR noshade size=\"1px\">\n");
--- 440,449 ----
      storeBuffer(e);
      storeAppendPrintf(e, "</PRE>\n");
      if (ftpState->flags.listformat_unknown && !ftpState->flags.tried_nlst) {
! 	storeAppendPrintf(e, "<A HREF=\"%s/;type=d\">[As plain directory]</A>\n",
! 	    ftpState->flags.dir_slash ? rfc1738_escape_part(ftpState->filepath) : ".");
      } else if (ftpState->typecode == 'D') {
! 	const char *path = ftpState->flags.dir_slash ? ftpState->filepath : ".";
  	storeAppendPrintf(e, "<A HREF=\"%s/\">[As extended directory]</A>\n", html_quote(path));
      }
      storeAppendPrintf(e, "<HR noshade size=\"1px\">\n");
***************
*** 681,686 ****
--- 685,691 ----
      LOCAL_ARRAY(char, download, 2048 + 40);
      LOCAL_ARRAY(char, link, 2048 + 40);
      LOCAL_ARRAY(char, html, 8192);
+     LOCAL_ARRAY(char, prefix, 2048);
      size_t width = Config.Ftp.list_width;
      ftpListParts *parts;
      *icon = *href = *text = *size = *chdir = *view = *download = *link = *html = '\0';
***************
*** 688,693 ****
--- 693,702 ----
  	snprintf(html, 8192, "%s\n", line);
  	return html;
      }
+     if (ftpState->flags.dir_slash)
+ 	snprintf(prefix, sizeof(prefix), "%s/", rfc1738_escape_part(ftpState->dirpath));
+     else
+ 	prefix[0] = '\0';
      /* Handle builtin <dirup> */
      if (strcmp(line, "<internal-dirup>") == 0) {
  	/* <A HREF="{href}">{icon}</A> <A HREF="{href}">{text}</A> {link} */
***************
*** 696,702 ****
  	    "[DIRUP]");
  	if (!ftpState->flags.no_dotdot && !ftpState->flags.root_dir) {
  	    /* Normal directory */
! 	    strcpy(href, "../");
  	    strcpy(text, "Parent Directory");
  	} else if (!ftpState->flags.no_dotdot && ftpState->flags.root_dir) {
  	    /* "Top level" directory */
--- 705,714 ----
  	    "[DIRUP]");
  	if (!ftpState->flags.no_dotdot && !ftpState->flags.root_dir) {
  	    /* Normal directory */
! 	    if (!ftpState->flags.dir_slash)
! 		strcpy(href, "../");
! 	    else
! 		strcpy(href, "./");
  	    strcpy(text, "Parent Directory");
  	} else if (!ftpState->flags.no_dotdot && ftpState->flags.root_dir) {
  	    /* "Top level" directory */
***************
*** 710,716 ****
  	    strcpy(href, "%2e%2e/");
  	    strcpy(text, "Parent Directory");
  	    snprintf(link, 2048, "(<A HREF=\"%s\">%s</A>)",
! 		"../",
  		"Back");
  	} else {		/* NO_DOTDOT && ROOT_DIR */
  	    /* "UNIX Root" directory */
--- 722,728 ----
  	    strcpy(href, "%2e%2e/");
  	    strcpy(text, "Parent Directory");
  	    snprintf(link, 2048, "(<A HREF=\"%s\">%s</A>)",
! 		!ftpState->flags.dir_slash ? "../" : "./",
  		"Back");
  	} else {		/* NO_DOTDOT && ROOT_DIR */
  	    /* "UNIX Root" directory */
***************
*** 758,765 ****
  	/* sometimes there is an 'l' flag, but no "->" link */
  	if (parts->link) {
  	    char *link2 = xstrdup(html_quote(rfc1738_escape(parts->link)));
! 	    snprintf(link, 2048, " -> <A HREF=\"%s\">%s</A>",
! 		link2,
  		html_quote(parts->link));
  	    safe_free(link2);
  	}
--- 770,777 ----
  	/* sometimes there is an 'l' flag, but no "->" link */
  	if (parts->link) {
  	    char *link2 = xstrdup(html_quote(rfc1738_escape(parts->link)));
! 	    snprintf(link, 2048, " -> <A HREF=\"%s%s\">%s</A>",
! 		*link2 != '/' ? prefix : "", link2,
  		html_quote(parts->link));
  	    safe_free(link2);
  	}
***************
*** 799,825 ****
      }
      if (parts->type != 'd') {
  	if (mimeGetViewOption(parts->name)) {
! 	    snprintf(view, 2048, " <A HREF=\"%s;type=a\"><IMG border=\"0\" SRC=\"%s\" "
  		"ALT=\"[VIEW]\"></A>",
! 		href, mimeGetIconURL("internal-view"));
  	}
  	if (mimeGetDownloadOption(parts->name)) {
! 	    snprintf(download, 2048, " <A HREF=\"%s;type=i\"><IMG border=\"0\" SRC=\"%s\" "
  		"ALT=\"[DOWNLOAD]\"></A>",
! 		href, mimeGetIconURL("internal-download"));
  	}
      }
      /* <A HREF="{href}">{icon}</A> <A HREF="{href}">{text}</A> . . . {date}{size}{chdir}{view}{download}{link}\n  */
      if (parts->type != '\0') {
! 	snprintf(html, 8192, "<A HREF=\"%s\">%s</A> <A HREF=\"%s\">%s</A>%s "
  	    "%s%8s%s%s%s%s\n",
! 	    href, icon, href, html_quote(text), dots_fill(strlen(text)),
  	    parts->date, size, chdir, view, download, link);
      } else {
  	/* Plain listing. {icon} {text} ... {chdir}{view}{download} */
! 	snprintf(html, 8192, "<A HREF=\"%s\">%s</A> <A HREF=\"%s\">%s</A>%s "
  	    "%s%s%s%s\n",
! 	    href, icon, href, html_quote(text), dots_fill(strlen(text)),
  	    chdir, view, download, link);
      }
      ftpListPartsFree(&parts);
--- 811,837 ----
      }
      if (parts->type != 'd') {
  	if (mimeGetViewOption(parts->name)) {
! 	    snprintf(view, 2048, " <A HREF=\"%s%s;type=a\"><IMG border=\"0\" SRC=\"%s\" "
  		"ALT=\"[VIEW]\"></A>",
! 		prefix, href, mimeGetIconURL("internal-view"));
  	}
  	if (mimeGetDownloadOption(parts->name)) {
! 	    snprintf(download, 2048, " <A HREF=\"%s%s;type=i\"><IMG border=\"0\" SRC=\"%s\" "
  		"ALT=\"[DOWNLOAD]\"></A>",
! 		prefix, href, mimeGetIconURL("internal-download"));
  	}
      }
      /* <A HREF="{href}">{icon}</A> <A HREF="{href}">{text}</A> . . . {date}{size}{chdir}{view}{download}{link}\n  */
      if (parts->type != '\0') {
! 	snprintf(html, 8192, "<A HREF=\"%s%s\">%s</A> <A HREF=\"%s%s\">%s</A>%s "
  	    "%s%8s%s%s%s%s\n",
! 	    prefix, href, icon, prefix, href, html_quote(text), dots_fill(strlen(text)),
  	    parts->date, size, chdir, view, download, link);
      } else {
  	/* Plain listing. {icon} {text} ... {chdir}{view}{download} */
! 	snprintf(html, 8192, "<A HREF=\"%s%s\">%s</A> <A HREF=\"%s%s\">%s</A>%s "
  	    "%s%s%s%s\n",
! 	    prefix, href, icon, prefix, href, html_quote(text), dots_fill(strlen(text)),
  	    chdir, view, download, link);
      }
      ftpListPartsFree(&parts);
***************
*** 1557,1563 ****
      debug(9, 4) ("ftpTraverseDirectory %s\n",
  	ftpState->filepath ? ftpState->filepath : "<NULL>");
  
!     safe_free(ftpState->filepath);
      /* Done? */
      if (ftpState->pathcomps == NULL) {
  	debug(9, 3) ("the final component was a directory\n");
--- 1569,1578 ----
      debug(9, 4) ("ftpTraverseDirectory %s\n",
  	ftpState->filepath ? ftpState->filepath : "<NULL>");
  
!     safe_free(ftpState->dirpath);
!     ftpState->dirpath = ftpState->filepath;
!     ftpState->filepath = NULL;
! 
      /* Done? */
      if (ftpState->pathcomps == NULL) {
  	debug(9, 3) ("the final component was a directory\n");
***************
*** 1662,1668 ****
  	debug(9, 3) ("Directory path did not end in /\n");
  	strCat(ftpState->title_url, "/");
  	ftpState->flags.isdir = 1;
! 	ftpState->flags.use_base = 1;
      }
      ftpSendPasv(ftpState);
  }
--- 1677,1683 ----
  	debug(9, 3) ("Directory path did not end in /\n");
  	strCat(ftpState->title_url, "/");
  	ftpState->flags.isdir = 1;
! 	ftpState->flags.dir_slash = 1;
      }
      ftpSendPasv(ftpState);
  }
 
design & coding: Vladimir Lettiev aka crux © 2004-2005