Package: thy
Version: 0.9.4-1.1
Severity: wishlist
Tags: patch

Hi,

as I store my file names as UTF-8, I need thy to add the appropirate
meta header to the directory indexes. Attached is a script that does
that in a configurable way. Info-Documentation updated.

Greetings from DebConf, Helsinki,
Joachim

-- System Information:
Debian Release: testing/unstable
  APT prefers unstable
  APT policy: (500, 'unstable'), (1, 'experimental')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.10.otto
Locale: LANG=de_DE.UTF-8, LC_CTYPE=de_DE.UTF-8 (charmap=UTF-8)

Versions of packages thy depends on:
ii  libc6                       2.3.2.ds1-22 GNU C Library: Shared libraries an
ii  libgnutls11                 1.0.16-13.1  GNU TLS library - runtime library
ii  zlib1g                      1:1.2.2-8    compression library - runtime

thy recommends no packages.

-- no debconf information
diff -ru thy-0.9.4/debian/changelog thy-0.9.4-my/debian/changelog
--- thy-0.9.4/debian/changelog  2005-07-14 16:53:49.789977936 +0300
+++ thy-0.9.4-my/debian/changelog       2005-07-14 15:31:16.589978792 +0300
@@ -1,3 +1,9 @@
+thy (0.9.4-1.1) UNRELEASED; urgency=low
+
+  * Added FileEncoding support
+
+ -- Joachim Breitner <[EMAIL PROTECTED]>  Thu, 14 Jul 2005 15:31:09 +0300
+
 thy (0.9.4-1) unstable; urgency=high
 
   * The `Some Other Level' release.
diff -ru thy-0.9.4/doc/thy.texi thy-0.9.4-my/doc/thy.texi
--- thy-0.9.4/doc/thy.texi      2004-10-30 15:06:24.000000000 +0300
+++ thy-0.9.4-my/doc/thy.texi   2005-07-14 15:51:43.104520240 +0300
@@ -534,6 +534,14 @@
 Default is @file{/var/www}.
 @end display
 
[EMAIL PROTECTED],STRING,fileencoding,f,ENCODING}
[EMAIL PROTECTED]
[EMAIL PROTECTED] specifies the character encoding that is used for
+filename.
+
+Default is @samp{iso-8859-1}
[EMAIL PROTECTED] display
+
 @cfgopt{ErrorDoc,PAIR,errordoc,e,CODE=PATH}
 @display
 Set the error-document for @samp{CODE} the file specified with
diff -ru thy-0.9.4/src/cfg_grammar.y thy-0.9.4-my/src/cfg_grammar.y
--- thy-0.9.4/src/cfg_grammar.y 2004-10-30 15:06:24.000000000 +0300
+++ thy-0.9.4-my/src/cfg_grammar.y      2005-07-14 16:51:41.717447920 +0300
@@ -54,7 +54,7 @@
 %token COMMENT ERROR
 
 %token T_BOOL_OFF T_BOOL_ON
-%token T_DOCUMENTROOT T_LISTEN T_DEFAULT_TYPE T_TIMEOUT
+%token T_DOCUMENTROOT T_LISTEN T_DEFAULT_TYPE T_TIMEOUT T_FILEENCODING
 %token T_USERDIR T_UID T_PIDFILE T_IPV4 T_IPV6 T_MAP T_INDEXES
 %token T_CGIEXTS T_ERRORDOC T_CGIDIRS T_ADDENV T_ADDHANDLER
 %token T_ADDMETHOD T_ADDHEADER T_ADDTYPE T_GZIP T_TYPE
@@ -106,6 +106,8 @@
 
                | T_DOCUMENTROOT T_STRING { add_arg ("-w", $2); }
 
+               | T_FILEENCODING T_STRING { add_arg ("-f", $2); }
+
                | T_LISTEN T_STRING { add_arg ("-l", $2); }
                | T_IPV4 { bhl_list_append_string (conffile_list, "-4"); }
                | T_IPV6 { bhl_list_append_string (conffile_list, "-6"); }
diff -ru thy-0.9.4/src/cfg_lexer.l thy-0.9.4-my/src/cfg_lexer.l
--- thy-0.9.4/src/cfg_lexer.l   2004-10-30 15:06:24.000000000 +0300
+++ thy-0.9.4-my/src/cfg_lexer.l        2005-07-14 16:27:23.861075776 +0300
@@ -82,6 +82,7 @@
 MaxKeepAliveRequests   { return T_MAXKEEPALIVEREQUESTS; }
 
 DocumentRoot   { return T_DOCUMENTROOT; }
+FileEncoding   { return T_FILEENCODING; }
 Listen         { return T_LISTEN; }
 DefaultType    { return T_DEFAULT_TYPE; }
 Timeout                { return T_TIMEOUT; }
diff -ru thy-0.9.4/src/config.c thy-0.9.4-my/src/config.c
--- thy-0.9.4/src/config.c      2004-10-30 15:06:24.000000000 +0300
+++ thy-0.9.4-my/src/config.c   2005-07-14 16:27:42.595227752 +0300
@@ -145,6 +145,7 @@
   {"unmap", 'F', NULL, OPTION_HIDDEN, "Globalise subsequent options", 1},
   {"alias", 'A', "SOURCE=DEST", 0, "Add a new alias", 1},
   {"cache-control", 'X', "FIELD=VALUE", 0, "Change cache control options", 1},
+  {"fileencoding", 'f', "ENCODING", 0, "Character encoding of the filenames", 
1},
   {0, 0, 0, 0, NULL, 0}
 };
 static error_t _config_parse_opt (int key, char *arg,
@@ -1396,6 +1397,9 @@
       if (wl > 1 && map_cfg->webroot[wl - 1] == '/')
        map_cfg->webroot[wl - 1] = '\0';
       break;
+    case 'f':
+      map_cfg->fileencoding = bhc_strdup (arg);
+    break;
     case 't':
       subopts = arg;
       while (*subopts != '\0')
@@ -1489,6 +1493,7 @@
   thy_default_config.webroot = _THY_WEBROOT;
   thy_default_config.default_type = _THY_DEFTYPE;
   thy_default_config.userdir = _THY_USERDIR;
+  thy_default_config.fileencoding = _THY_FILEENCODING;
 
   thy_default_config.options.userdir = THY_BOOL_TRUE;
   thy_default_config.options.vhosting = THY_BOOL_FALSE;
@@ -1744,6 +1749,8 @@
        cfg->default_type = map->config->default_type;
       if (map->config->userdir)
        cfg->userdir = map->config->userdir;
+      if (map->config->fileencoding)
+       cfg->fileencoding = map->config->fileencoding;
       for (j = HTTP_STATUS_100; j < HTTP_STATUS_UNKNOWN; j++)
        {
          if (map->config->http_status[j])
diff -ru thy-0.9.4/src/dirindex.c thy-0.9.4-my/src/dirindex.c
--- thy-0.9.4/src/dirindex.c    2004-10-30 15:06:24.000000000 +0300
+++ thy-0.9.4-my/src/dirindex.c 2005-07-14 15:30:48.313277504 +0300
@@ -148,11 +148,12 @@
  *
  * @param path is the path to index.
  * @param url is the URL we do the indexing for.
+ * @param fileencoding is the configures encoding for filenames
  *
  * @returns The directory index, or NULL on error.
  */
 char *
-directory_index (const char *path, const char *url)
+directory_index (const char *path, const char *url, const char *fileencoding)
 {
   struct dirent **namelist;
   struct stat st;
@@ -260,6 +261,7 @@
            "Transitional//EN\">"
            "\n"
            "<html>\n<head>\n <title>Directory listing of %s</title>\n"
+           " <meta http-equiv=\"Content-Type\" content=\"text/html; 
charset=%s\">\n"
            " <meta name=\"generator\" content=\"%s\">\n"
            "</head>\n<body bgcolor=\"#ffffff\" text=\"#000000\">\n"
            "<h2>Index of %s</h2>\n<table width=\"100%%\">\n"
@@ -268,7 +270,7 @@
            "%s"
            "</table>\n<hr noshade>\nIndex generated %s by %s\n"
            "</body>\n</html>\n",
-           hurl, thy_servername (NULL), hurl, (d_dirs) ? h_dirs : "",
+           hurl, fileencoding, thy_servername (NULL), hurl, (d_dirs) ? h_dirs 
: "",
            (d_files) ? h_files : "",  t, servername);
 
   free (hurl);
diff -ru thy-0.9.4/src/dirindex.h thy-0.9.4-my/src/dirindex.h
--- thy-0.9.4/src/dirindex.h    2004-10-30 15:06:24.000000000 +0300
+++ thy-0.9.4-my/src/dirindex.h 2005-07-14 15:31:01.839221248 +0300
@@ -25,6 +25,6 @@
 #ifndef _THY_DIRINDEX_H
 #define _THY_DIRINDEX_H 1 /**< dirindex.h multi-inclusion guard. */
 
-char *directory_index (const char *path, const char *url);
+char *directory_index (const char *path, const char *url, const char 
*fileencoding);
 
 #endif /* !_THY_DIRINDEX_H */
diff -ru thy-0.9.4/src/session.c thy-0.9.4-my/src/session.c
--- thy-0.9.4/src/session.c     2004-10-30 15:06:24.000000000 +0300
+++ thy-0.9.4-my/src/session.c  2005-07-14 16:01:25.027054568 +0300
@@ -505,12 +505,14 @@
                                          session->conntime,
                                          config->timeout)) == NULL)
     di = directory_index (session->request->resolved,
-                         session->request->url);
+                         session->request->url,
+                         map_config->fileencoding);
   else
     {
       if (buf.st_mtime > csession->conntime)
        di = directory_index (session->request->resolved,
-                             session->request->url);
+                             session->request->url,
+                             map_config->fileencoding);
       else
        di = bhc_strdup (csession->body.buffer);
     }
diff -ru thy-0.9.4/src/thy.h thy-0.9.4-my/src/thy.h
--- thy-0.9.4/src/thy.h 2004-10-30 15:06:24.000000000 +0300
+++ thy-0.9.4-my/src/thy.h      2005-07-14 15:56:25.549582064 +0300
@@ -83,6 +83,7 @@
                                        version. */
 #define _THY_WORKER_PROTOCOL_VERSION 1 /**< Worker protocol
                                          version. */
+#define _THY_FILEENCODING "iso-8859-1" /**< Default Filename Encoding */
 
 #ifndef __DOXYGEN__
 #if SIZEOF_SIZE_T == 4
diff -ru thy-0.9.4/src/types.h thy-0.9.4-my/src/types.h
--- thy-0.9.4/src/types.h       2004-10-30 15:06:24.000000000 +0300
+++ thy-0.9.4-my/src/types.h    2005-07-14 16:01:04.488176952 +0300
@@ -482,6 +482,8 @@
   char *http_status[HTTP_STATUS_UNKNOWN]; /**< HTTP status code to
                                             error document mapping
                                             table. */
+  
+  char *fileencoding; /**< Fileencoding of file names */
 
   /** Options settable via -o.
    */

Reply via email to