diff --git a/bin/webs.c b/bin/webs.c
index 3387733..b5a30c0 100644
--- a/bin/webs.c
+++ b/bin/webs.c
@@ -23,7 +23,7 @@ typedef struct arg_info_t arg_info_t;
struct htts_ext_t
{
- arg_info_t* ai;
+ const arg_info_t* ai;
};
typedef struct htts_ext_t htts_ext_t;
@@ -102,7 +102,7 @@ static int file_open_dir_list (hio_svc_htts_t* htts, const hio_bch_t* qpath, con
if (ext->ai->file_load_index_page)
{
- const hio_bch_t* index_path;
+ hio_bch_t* index_path;
index_path = hio_svc_htts_dupmergepaths(htts, dir_path, "index.html");
if (HIO_UNLIKELY(!index_path)) goto oops;
@@ -135,7 +135,7 @@ static int file_open_dir_list (hio_svc_htts_t* htts, const hio_bch_t* qpath, con
unlink (file_path);
write (fd, "
", 12);
- if (qpath[0] == '\0' || (qpath[0] == '/' && qpath[1] == '\0'))
+ if (!(qpath[0] == '\0' || (qpath[0] == '/' && qpath[1] == '\0')))
write (fd, "..", 23);
/* TODO: sorting, other informatino like size, */
@@ -143,17 +143,28 @@ static int file_open_dir_list (hio_svc_htts_t* htts, const hio_bch_t* qpath, con
while ((de = readdir(dp)))
{
struct stat st;
+ hio_bch_t* tmp_path;
+ int n;
if ((de->d_name[0] == '.' && de->d_name[1] == '\0') ||
(de->d_name[0] == '.' && de->d_name[1] == '.' && de->d_name[2] == '\0')) continue;
- if (stat(de->d_name, &st) <= -1) continue;
+ tmp_path = hio_svc_htts_dupmergepaths(htts, dir_path, de->d_name);
+ if (HIO_UNLIKELY(!tmp_path)) continue;
+ n = stat(tmp_path, &st);
+ hio_freemem (hio, tmp_path);
+ if (HIO_UNLIKELY(n <= -1)) continue;
write (fd, "d_name, strlen(de->d_name)); /* TOOD: url escaping*/
+ {
+ char tmp[1000]; /* TODO:use dynamic buffer?? */
+ hio_perenc_http_bcstr(0, de->d_name, tmp, HIO_NULL); /* url encoding */
+ //write (fd, de->d_name, strlen(de->d_name));
+ write (fd, tmp, strlen(tmp));
+ }
if (S_ISDIR(st.st_mode)) write (fd, "/", 1);
write (fd, "\">", 2);
- write (fd, de->d_name, strlen(de->d_name));
+ write (fd, de->d_name, strlen(de->d_name)); /* TODO: html entity encoding */
if (S_ISDIR(st.st_mode)) write (fd, "/", 1);
write (fd, "", 4);
}
diff --git a/lib/hio-http.h b/lib/hio-http.h
index ec4d2ff..4cf8f04 100644
--- a/lib/hio-http.h
+++ b/lib/hio-http.h
@@ -236,7 +236,7 @@ HIO_EXPORT int hio_is_perenced_http_bcstr (
* The hio_perdec_http_bcstr() function performs percent-decoding over a string.
* The caller must ensure that the output buffer \a buf is large enough.
* If \a ndecs is not #HIO_NULL, it is set to the number of characters
- * decoded. 0 means no characters in the input string required decoding
+ * decoded. 0 means no characters in the input string required decoding
* \return the length of the output string.
*/
HIO_EXPORT hio_oow_t hio_perdec_http_bcstr (
@@ -259,7 +259,7 @@ HIO_EXPORT hio_oow_t hio_perdec_http_bcs (
* The hio_perenc_http_bcstr() function performs percent-encoding over a string.
* The caller must ensure that the output buffer \a buf is large enough.
* If \a nencs is not #HIO_NULL, it is set to the number of characters
- * encoded. 0 means no characters in the input string required encoding.
+ * encoded. 0 means no characters in the input string required encoding.
* \return the length of the output string.
*/
HIO_EXPORT hio_oow_t hio_perenc_http_bcstr (