]> git.pld-linux.org Git - packages/squid.git/blame - squid-2.5.STABLE10-ftp_basehref.patch
- updated to 2.5.STABLE13
[packages/squid.git] / squid-2.5.STABLE10-ftp_basehref.patch
CommitLineData
657376c6 1Index: squid/src/ftp.c
2diff -c squid/src/ftp.c:1.316.2.26 squid/src/ftp.c:1.316.2.27
3*** squid/src/ftp.c:1.316.2.26 Tue Jun 21 16:18:19 2005
4--- squid/src/ftp.c Tue Jun 21 16:21:31 2005
5***************
6*** 69,74 ****
7--- 69,75 ----
8 unsigned int http_header_sent:1;
9 unsigned int tried_nlst:1;
10 unsigned int use_base:1;
11+ unsigned int dir_slash:1;
12 unsigned int root_dir:1;
13 unsigned int no_dotdot:1;
14 unsigned int html_header_sent:1;
15***************
16*** 87,92 ****
17--- 88,94 ----
18 int password_url;
19 char *reply_hdr;
20 int reply_hdr_state;
21+ String clean_url;
22 String title_url;
23 String base_href;
24 int conn_att;
25***************
26*** 96,101 ****
27--- 98,104 ----
28 squid_off_t size;
29 wordlist *pathcomps;
30 char *filepath;
31+ char *dirpath;
32 squid_off_t restart_offset;
33 squid_off_t restarted_offset;
34 int rest_att;
35***************
36*** 437,445 ****
37 storeBuffer(e);
38 storeAppendPrintf(e, "</PRE>\n");
39 if (ftpState->flags.listformat_unknown && !ftpState->flags.tried_nlst) {
40! storeAppendPrintf(e, "<A HREF=\"./;type=d\">[As plain directory]</A>\n");
41 } else if (ftpState->typecode == 'D') {
42! const char *path = ftpState->filepath ? ftpState->filepath : ".";
43 storeAppendPrintf(e, "<A HREF=\"%s/\">[As extended directory]</A>\n", html_quote(path));
44 }
45 storeAppendPrintf(e, "<HR noshade size=\"1px\">\n");
46--- 440,449 ----
47 storeBuffer(e);
48 storeAppendPrintf(e, "</PRE>\n");
49 if (ftpState->flags.listformat_unknown && !ftpState->flags.tried_nlst) {
50! storeAppendPrintf(e, "<A HREF=\"%s/;type=d\">[As plain directory]</A>\n",
51! ftpState->flags.dir_slash ? rfc1738_escape_part(ftpState->filepath) : ".");
52 } else if (ftpState->typecode == 'D') {
53! const char *path = ftpState->flags.dir_slash ? ftpState->filepath : ".";
54 storeAppendPrintf(e, "<A HREF=\"%s/\">[As extended directory]</A>\n", html_quote(path));
55 }
56 storeAppendPrintf(e, "<HR noshade size=\"1px\">\n");
57***************
58*** 681,686 ****
59--- 685,691 ----
60 LOCAL_ARRAY(char, download, 2048 + 40);
61 LOCAL_ARRAY(char, link, 2048 + 40);
62 LOCAL_ARRAY(char, html, 8192);
63+ LOCAL_ARRAY(char, prefix, 2048);
64 size_t width = Config.Ftp.list_width;
65 ftpListParts *parts;
66 *icon = *href = *text = *size = *chdir = *view = *download = *link = *html = '\0';
67***************
68*** 688,693 ****
69--- 693,702 ----
70 snprintf(html, 8192, "%s\n", line);
71 return html;
72 }
73+ if (ftpState->flags.dir_slash)
74+ snprintf(prefix, sizeof(prefix), "%s/", rfc1738_escape_part(ftpState->dirpath));
75+ else
76+ prefix[0] = '\0';
77 /* Handle builtin <dirup> */
78 if (strcmp(line, "<internal-dirup>") == 0) {
79 /* <A HREF="{href}">{icon}</A> <A HREF="{href}">{text}</A> {link} */
80***************
81*** 696,702 ****
82 "[DIRUP]");
83 if (!ftpState->flags.no_dotdot && !ftpState->flags.root_dir) {
84 /* Normal directory */
85! strcpy(href, "../");
86 strcpy(text, "Parent Directory");
87 } else if (!ftpState->flags.no_dotdot && ftpState->flags.root_dir) {
88 /* "Top level" directory */
89--- 705,714 ----
90 "[DIRUP]");
91 if (!ftpState->flags.no_dotdot && !ftpState->flags.root_dir) {
92 /* Normal directory */
93! if (!ftpState->flags.dir_slash)
94! strcpy(href, "../");
95! else
96! strcpy(href, "./");
97 strcpy(text, "Parent Directory");
98 } else if (!ftpState->flags.no_dotdot && ftpState->flags.root_dir) {
99 /* "Top level" directory */
100***************
101*** 710,716 ****
102 strcpy(href, "%2e%2e/");
103 strcpy(text, "Parent Directory");
104 snprintf(link, 2048, "(<A HREF=\"%s\">%s</A>)",
105! "../",
106 "Back");
107 } else { /* NO_DOTDOT && ROOT_DIR */
108 /* "UNIX Root" directory */
109--- 722,728 ----
110 strcpy(href, "%2e%2e/");
111 strcpy(text, "Parent Directory");
112 snprintf(link, 2048, "(<A HREF=\"%s\">%s</A>)",
113! !ftpState->flags.dir_slash ? "../" : "./",
114 "Back");
115 } else { /* NO_DOTDOT && ROOT_DIR */
116 /* "UNIX Root" directory */
117***************
118*** 758,765 ****
119 /* sometimes there is an 'l' flag, but no "->" link */
120 if (parts->link) {
121 char *link2 = xstrdup(html_quote(rfc1738_escape(parts->link)));
122! snprintf(link, 2048, " -> <A HREF=\"%s\">%s</A>",
123! link2,
124 html_quote(parts->link));
125 safe_free(link2);
126 }
127--- 770,777 ----
128 /* sometimes there is an 'l' flag, but no "->" link */
129 if (parts->link) {
130 char *link2 = xstrdup(html_quote(rfc1738_escape(parts->link)));
131! snprintf(link, 2048, " -> <A HREF=\"%s%s\">%s</A>",
132! *link2 != '/' ? prefix : "", link2,
133 html_quote(parts->link));
134 safe_free(link2);
135 }
136***************
137*** 799,825 ****
138 }
139 if (parts->type != 'd') {
140 if (mimeGetViewOption(parts->name)) {
141! snprintf(view, 2048, " <A HREF=\"%s;type=a\"><IMG border=\"0\" SRC=\"%s\" "
142 "ALT=\"[VIEW]\"></A>",
143! href, mimeGetIconURL("internal-view"));
144 }
145 if (mimeGetDownloadOption(parts->name)) {
146! snprintf(download, 2048, " <A HREF=\"%s;type=i\"><IMG border=\"0\" SRC=\"%s\" "
147 "ALT=\"[DOWNLOAD]\"></A>",
148! href, mimeGetIconURL("internal-download"));
149 }
150 }
151 /* <A HREF="{href}">{icon}</A> <A HREF="{href}">{text}</A> . . . {date}{size}{chdir}{view}{download}{link}\n */
152 if (parts->type != '\0') {
153! snprintf(html, 8192, "<A HREF=\"%s\">%s</A> <A HREF=\"%s\">%s</A>%s "
154 "%s%8s%s%s%s%s\n",
155! href, icon, href, html_quote(text), dots_fill(strlen(text)),
156 parts->date, size, chdir, view, download, link);
157 } else {
158 /* Plain listing. {icon} {text} ... {chdir}{view}{download} */
159! snprintf(html, 8192, "<A HREF=\"%s\">%s</A> <A HREF=\"%s\">%s</A>%s "
160 "%s%s%s%s\n",
161! href, icon, href, html_quote(text), dots_fill(strlen(text)),
162 chdir, view, download, link);
163 }
164 ftpListPartsFree(&parts);
165--- 811,837 ----
166 }
167 if (parts->type != 'd') {
168 if (mimeGetViewOption(parts->name)) {
169! snprintf(view, 2048, " <A HREF=\"%s%s;type=a\"><IMG border=\"0\" SRC=\"%s\" "
170 "ALT=\"[VIEW]\"></A>",
171! prefix, href, mimeGetIconURL("internal-view"));
172 }
173 if (mimeGetDownloadOption(parts->name)) {
174! snprintf(download, 2048, " <A HREF=\"%s%s;type=i\"><IMG border=\"0\" SRC=\"%s\" "
175 "ALT=\"[DOWNLOAD]\"></A>",
176! prefix, href, mimeGetIconURL("internal-download"));
177 }
178 }
179 /* <A HREF="{href}">{icon}</A> <A HREF="{href}">{text}</A> . . . {date}{size}{chdir}{view}{download}{link}\n */
180 if (parts->type != '\0') {
181! snprintf(html, 8192, "<A HREF=\"%s%s\">%s</A> <A HREF=\"%s%s\">%s</A>%s "
182 "%s%8s%s%s%s%s\n",
183! prefix, href, icon, prefix, href, html_quote(text), dots_fill(strlen(text)),
184 parts->date, size, chdir, view, download, link);
185 } else {
186 /* Plain listing. {icon} {text} ... {chdir}{view}{download} */
187! snprintf(html, 8192, "<A HREF=\"%s%s\">%s</A> <A HREF=\"%s%s\">%s</A>%s "
188 "%s%s%s%s\n",
189! prefix, href, icon, prefix, href, html_quote(text), dots_fill(strlen(text)),
190 chdir, view, download, link);
191 }
192 ftpListPartsFree(&parts);
193***************
194*** 1557,1563 ****
195 debug(9, 4) ("ftpTraverseDirectory %s\n",
196 ftpState->filepath ? ftpState->filepath : "<NULL>");
197
198! safe_free(ftpState->filepath);
199 /* Done? */
200 if (ftpState->pathcomps == NULL) {
201 debug(9, 3) ("the final component was a directory\n");
202--- 1569,1578 ----
203 debug(9, 4) ("ftpTraverseDirectory %s\n",
204 ftpState->filepath ? ftpState->filepath : "<NULL>");
205
206! safe_free(ftpState->dirpath);
207! ftpState->dirpath = ftpState->filepath;
208! ftpState->filepath = NULL;
209!
210 /* Done? */
211 if (ftpState->pathcomps == NULL) {
212 debug(9, 3) ("the final component was a directory\n");
213***************
214*** 1662,1668 ****
215 debug(9, 3) ("Directory path did not end in /\n");
216 strCat(ftpState->title_url, "/");
217 ftpState->flags.isdir = 1;
218! ftpState->flags.use_base = 1;
219 }
220 ftpSendPasv(ftpState);
221 }
222--- 1677,1683 ----
223 debug(9, 3) ("Directory path did not end in /\n");
224 strCat(ftpState->title_url, "/");
225 ftpState->flags.isdir = 1;
226! ftpState->flags.dir_slash = 1;
227 }
228 ftpSendPasv(ftpState);
229 }
This page took 0.071033 seconds and 4 git commands to generate.