+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
FILE *fp;
char *upwd;
char *htclfile; /* HTML-clean file name */
+ char *urlclfile; /* URL-clean file name */
if (!output_stream)
{
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);
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");
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. */
/* 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);