myserver-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[myserver-commit] [SCM] GNU MyServer branch, master, updated. v0.9.2-425


From: Giuseppe Scrivano
Subject: [myserver-commit] [SCM] GNU MyServer branch, master, updated. v0.9.2-425-gd2eca5b
Date: Tue, 01 Feb 2011 15:17:47 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU MyServer".

The branch, master has been updated
       via  d2eca5ba371154230cac112f8bb9e502b87facc6 (commit)
       via  e76f9dd9b35dc6d4202cb0657d4086cba7d8e079 (commit)
       via  52f8d5ba3e91dd27d2eb79ddbf0c061656b3a5d8 (commit)
       via  6b1d5d7e13577e07cae518900db43eb1e805eece (commit)
      from  861e1b03871e68f677878810059e1b76db0f00a4 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------


commit d2eca5ba371154230cac112f8bb9e502b87facc6
Author: Giuseppe Scrivano <address@hidden>
Date:   Tue Feb 1 16:14:10 2011 +0100

    tests: add test for UTF-8 encoded URLs.

diff --git a/myserver/tests/test_stringutils.cpp 
b/myserver/tests/test_stringutils.cpp
index 8bdb6bc..100dee8 100644
--- a/myserver/tests/test_stringutils.cpp
+++ b/myserver/tests/test_stringutils.cpp
@@ -142,6 +142,8 @@ public:
     CPPUNIT_ASSERT (translateSingleEscapeString ("foo+", "foo "));
     CPPUNIT_ASSERT (translateSingleEscapeString ("fooo+", "fooo "));
     CPPUNIT_ASSERT (translateSingleEscapeString ("%301%323%34", "01234"));
+    CPPUNIT_ASSERT (translateSingleEscapeString ("%c3%a2%c2%9c%c2%88", "✈"));
+    CPPUNIT_ASSERT (translateSingleEscapeString 
("%c3%a2%c2%9c%c2%88%c3%a2%c2%9c%c2%88", "✈✈"));
   }
 
 private:



commit e76f9dd9b35dc6d4202cb0657d4086cba7d8e079
Author: Giuseppe Scrivano <address@hidden>
Date:   Tue Feb 1 15:31:42 2011 +0100

    HttpDir: print the UTF-8 version of the directory name.

diff --git a/myserver/src/http_handler/http_dir/http_dir.cpp 
b/myserver/src/http_handler/http_dir/http_dir.cpp
index 60b5c91..36fb6ec 100644
--- a/myserver/src/http_handler/http_dir/http_dir.cpp
+++ b/myserver/src/http_handler/http_dir/http_dir.cpp
@@ -417,8 +417,13 @@ int HttpDir::send (HttpThreadContext* td,
 
       filename = directory;
       td->auxiliaryBuffer->setLength (0);
+
+      size_t lastIndex = filename.rfind ("/");
+      if (lastIndex == string::npos)
+        lastIndex = filename.rfind ("\\");
       *td->auxiliaryBuffer << "<body>\r\n<h1>Contents of directory ";
-      *td->auxiliaryBuffer <<  &td->request.uri[lastSlash] ;
+      *td->auxiliaryBuffer << &filename.c_str ()[lastIndex != string::npos
+                                                 ? lastIndex + 1: 0];
       *td->auxiliaryBuffer << "</h1>\r\n<hr />\r\n";
 
       appendDataToHTTPChannel (td, td->auxiliaryBuffer->getBuffer (),
@@ -649,6 +654,5 @@ void HttpDir::formatHtml (string& in, string& out)
                    0x80 | ((c >> 6) & 0x3F), 0x80 | (c & 0x3F));
           out.append (buf);
         }
-
     }
 }



commit 52f8d5ba3e91dd27d2eb79ddbf0c061656b3a5d8
Author: Giuseppe Scrivano <address@hidden>
Date:   Tue Feb 1 15:29:25 2011 +0100

    Support UTF-8 encoded URLs

diff --git a/myserver/NEWS b/myserver/NEWS
index 583f3d4..ae3f94f 100644
--- a/myserver/NEWS
+++ b/myserver/NEWS
@@ -11,6 +11,10 @@ GNU myserver NEWS                                    -*- 
outline -*-
    The proxy handler doesn't use the chunked transfer encoding when the
    content-length is known, both methods were used at the same time.
 
+** New features
+
+   Support UTF-8 encoded URLs.
+
 * Noteworthy changes in release 0.10
 
 ** Bug fixes
diff --git a/myserver/src/base/string/stringutils.cpp 
b/myserver/src/base/string/stringutils.cpp
index 1fa6a54..11cf580 100644
--- a/myserver/src/base/string/stringutils.cpp
+++ b/myserver/src/base/string/stringutils.cpp
@@ -659,18 +659,52 @@ void gotoNextLine (char** cmd)
 #define TRANSLATE_ESCAPE_STRING_BODY                                    \
   if ((str[i] == '%') && str[i + 1] && str[i + 2])                      \
     {                                                                   \
-      str[j] =(char) (16 * hexVal (str[i + 1]) + hexVal (str[i + 2]));  \
+      b = (char) (16 * hexVal (str[i + 1]) + hexVal (str[i + 2]));      \
       i = i + 3;                                                        \
     }                                                                   \
   else if (str[i] == '+')                                               \
     {                                                                   \
-      str[j] = ' ';                                                     \
+      b = ' ';                                                          \
       i++;                                                              \
     }                                                                   \
   else                                                                  \
-    str[j] = str[i++];                                                  \
+    b = str[i++];                                                       \
                                                                         \
-  j++;
+  if ((b & 0xc0) == 0x80)                                               \
+    {                                                                   \
+      sum = (sum << 6) | (b & 0x3f);                                    \
+      if (--more == 0)                                                  \
+        str[j++] = sum;                                                 \
+    }                                                                   \
+  else if ((b & 0x80) == 0x00)                                          \
+    {                                                                   \
+      str[j++] = b;                                                     \
+    }                                                                   \
+  else if ((b & 0xe0) == 0xc0)                                          \
+    {                                                                   \
+      sum = b & 0x1f;                                                   \
+      more = 1;                                                         \
+    }                                                                   \
+  else if ((b & 0xf0) == 0xe0)                                          \
+    {                                                                   \
+      sum = b & 0x0f;                                                   \
+      more = 2;                                                         \
+    }                                                                   \
+  else if ((b & 0xf8) == 0xf0)                                          \
+    {                                                                   \
+      sum = b & 0x07;                                                   \
+      more = 3;                                                         \
+    }                                                                   \
+  else if ((b & 0xfc) == 0xf8)                                          \
+    {                                                                   \
+      sum = b & 0x03;                                                   \
+      more = 4;                                                         \
+    }                                                                   \
+  else                                                                  \
+    {                                                                   \
+      sum = b & 0x01;                                                   \
+      more = 5;                                                         \
+    }
 
 
 /*!
@@ -678,9 +712,8 @@ void gotoNextLine (char** cmd)
  */
 void translateEscapeString (char *str)
 {
-  int i, j;
-  i = 0;
-  j = 0;
+  int i = 0, j = 0;
+  unsigned char b, sum, more = -1;
   while (str[i] != 0)
     {
       TRANSLATE_ESCAPE_STRING_BODY
@@ -693,10 +726,8 @@ void translateEscapeString (char *str)
  */
 void translateEscapeString (string& str)
 {
-  int i, j, len;
-  i = 0;
-  j = 0;
-  len = str.length ();
+  int i = 0, j = 0, len = str.length ();
+  unsigned char b, sum, more = -1;
   while (i < len)
     {
       TRANSLATE_ESCAPE_STRING_BODY
diff --git a/myserver/src/protocol/http/http.cpp 
b/myserver/src/protocol/http/http.cpp
index 24f0637..d73077b 100644
--- a/myserver/src/protocol/http/http.cpp
+++ b/myserver/src/protocol/http/http.cpp
@@ -246,6 +246,9 @@ int Http::getFilePermissions (string& resource, string& 
directory, string& file,
 
       td->securityToken.setVhost (td->connection->host);
 
+      if (!yetmapped)
+        translateEscapeString (resource);
+
       FilesUtility::splitPath (resource, directory, file);
       FilesUtility::completePath (directory);
 
@@ -267,7 +270,6 @@ int Http::getFilePermissions (string& resource, string& 
directory, string& file,
             If the client tries to access files that aren't in the web 
directory
             send a HTTP 401 error page.
            */
-          translateEscapeString (resource);
           if ((resource[0] != '\0')
               && (FilesUtility::getPathRecursionLevel (resource) < 1))
             return 401;



commit 6b1d5d7e13577e07cae518900db43eb1e805eece
Author: Giuseppe Scrivano <address@hidden>
Date:   Tue Feb 1 01:30:44 2011 +0100

    HttpDir: show properly UTF-8 names.

diff --git a/myserver/src/http_handler/http_dir/http_dir.cpp 
b/myserver/src/http_handler/http_dir/http_dir.cpp
index dbad06e..60b5c91 100644
--- a/myserver/src/http_handler/http_dir/http_dir.cpp
+++ b/myserver/src/http_handler/http_dir/http_dir.cpp
@@ -246,7 +246,7 @@ void HttpDir::generateElement (MemBuf &out,
       out << "<td><a href=\"";
       out << linkPrefix << name;
       out << "\">" ;
-      out << name;
+      out << file.name;
       out << "</a></td>\r\n";
       break;
 
@@ -402,11 +402,9 @@ int HttpDir::send (HttpThreadContext* td,
         the browse directory insert it in the page.
        */
       if (cssFile)
-        {
-          *td->auxiliaryBuffer << "<link rel=\"stylesheet\" href=\""
-                               << cssFile
-                               << "\" type=\"text/css\" media=\"all\"/>\r\n";
-        }
+        *td->auxiliaryBuffer << "<link rel=\"stylesheet\" href=\""
+                             << cssFile
+                             << "\" type=\"text/css\" media=\"all\"/>\r\n";
 
       *td->auxiliaryBuffer << "</head>\r\n";
 
@@ -613,27 +611,44 @@ int HttpDir::send (HttpThreadContext* td,
  */
 void HttpDir::formatHtml (string& in, string& out)
 {
-  string::size_type pos = 0;
-  out.assign (in);
-  /*
-    Replace characters in the ranges 32-47 58-64 123-126 160-255
-    with "&#CODE;".
-   */
-  for (pos = 0; out[pos] != '\0'; pos++)
+  char tmp[2] = {'\0', '\0'};
+
+  for (int i = 0; i < in.size (); i++)
     {
-      if (((u_char) out[pos] >= 32
-           && (u_char) out[pos] <= 47)
-          || ((u_char) out[pos] >= 58
-              && (u_char) out[pos] <= 64)
-          || ((u_char) out[pos] >= 123
-              && (u_char) out[pos] <= 126)
-          || ((u_char) out[pos] >= 160
-              && (u_char) out[pos] < 255))
+      unsigned char c = (unsigned char) in[i];
+      if ((c >= 'a' && c <= 'z')
+          || (c >= 'A' && c <= 'Z')
+          || (c >= '0' && c <= '9')
+          || c == '-' || c == '_'
+          || c == '.' || c == '!'
+          || c == '~' || c == '*'
+          || c == '\'' || c == '('
+          || c == ')')
         {
-          ostringstream os;
-          os << "&#" << (int)((unsigned char) out[pos]) << ";";
-          out.replace (pos, 1, os.str ());
-          pos += os.str ().length () - 1;
+          tmp[0] = c;
+          out.append (tmp);
         }
+      else if (c == ' ')
+        out.append ("+");
+      else if (c <= 0x007f)
+        {
+          char buf[3];
+          sprintf (buf, "%%%x", c);
+          out.append (buf);
+        }
+      else if (c <= 0x07FF)
+        {
+          char buf[5];
+          sprintf (buf, "%%%x%%%x", 0xc0 | c >> 6, 0x80 | (c & 0x3F));
+          out.append (buf);
+        }
+      else
+        {
+          char buf[7];
+          sprintf (buf, "%%%x%%%x%%%x", 0xe0 | (c >> 12),
+                   0x80 | ((c >> 6) & 0x3F), 0x80 | (c & 0x3F));
+          out.append (buf);
+        }
+
     }
 }

-----------------------------------------------------------------------

Summary of changes:
 myserver/NEWS                                   |    4 +
 myserver/src/base/string/stringutils.cpp        |   53 +++++++++++++----
 myserver/src/http_handler/http_dir/http_dir.cpp |   71 ++++++++++++++--------
 myserver/src/protocol/http/http.cpp             |    4 +-
 myserver/tests/test_stringutils.cpp             |    2 +
 5 files changed, 96 insertions(+), 38 deletions(-)


hooks/post-receive
-- 
GNU MyServer



reply via email to

[Prev in Thread] Current Thread [Next in Thread]