Applied Alexander Belopolsky's patch for htmlified FTP listings.

This commit is contained in:
Micah Cowan 2008-11-12 20:47:52 -08:00
parent 1777835073
commit cf93ce7f4b
4 changed files with 21 additions and 1 deletions

View File

@ -1,3 +1,10 @@
2008-11-12 Alexander Belopolsky <alexander.belopolsky@gmail.com>
* url.c, url.h (url_escape_unsafe_and_reserved): Added.
* ftp-ls.c (ftp_index): URL-escape, rather than HTML-escape, the
filename appearing in the link.
2008-11-12 Steven Schubiger <stsc@members.fsf.org>
* main.c (print_version): Hand the relevant

View File

@ -851,6 +851,7 @@ ftp_index (const char *file, struct url *u, struct fileinfo *f)
FILE *fp;
char *upwd;
char *htclfile; /* HTML-clean file name */
char *urlclfile; /* URL-clean file name */
if (!output_stream)
{
@ -923,13 +924,14 @@ ftp_index (const char *file, struct url *u, struct fileinfo *f)
break;
}
htclfile = html_quote_string (f->name);
urlclfile = url_escape_unsafe_and_reserved (f->name);
fprintf (fp, "<a href=\"ftp://%s%s:%d", upwd, u->host, u->port);
if (*u->dir != '/')
putc ('/', fp);
fprintf (fp, "%s", u->dir);
if (*u->dir)
putc ('/', fp);
fprintf (fp, "%s", htclfile);
fprintf (fp, "%s", urlclfile);
if (f->type == FT_DIRECTORY)
putc ('/', fp);
fprintf (fp, "\">%s", htclfile);
@ -942,6 +944,7 @@ ftp_index (const char *file, struct url *u, struct fileinfo *f)
fprintf (fp, "-> %s", f->linkto ? f->linkto : "(nil)");
putc ('\n', fp);
xfree (htclfile);
xfree (urlclfile);
f = f->next;
}
fprintf (fp, "</pre>\n</body>\n</html>\n");

View File

@ -252,6 +252,15 @@ url_escape (const char *s)
return url_escape_1 (s, urlchr_unsafe, false);
}
/* URL-escape the unsafe and reserved characters (see urlchr_table) in
a given string, returning a freshly allocated string. */
char *
url_escape_unsafe_and_reserved (const char *s)
{
return url_escape_1 (s, urlchr_unsafe|urlchr_reserved, false);
}
/* URL-escape the unsafe characters (see urlchr_table) in a given
string. If no characters are unsafe, S is returned. */

View File

@ -83,6 +83,7 @@ struct url
/* Function declarations */
char *url_escape (const char *);
char *url_escape_unsafe_and_reserved (const char *);
struct url *url_parse (const char *, int *);
char *url_error (const char *, int);