monit-dev
[Top][All Lists]
Advanced

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

[monit-dev] [monit] r280 committed - Encode service names proper in URL


From: monit
Subject: [monit-dev] [monit] r280 committed - Encode service names proper in URL
Date: Fri, 24 Sep 2010 16:13:57 +0000

Revision: 280
Author: janhenrik.haukeland
Date: Fri Sep 24 09:13:19 2010
Log: Encode service names proper in URL
http://code.google.com/p/monit/source/detail?r=280

Modified:
 /trunk/control.c
 /trunk/http/cervlet.c
 /trunk/l.l
 /trunk/protocols/http.c
 /trunk/util.c
 /trunk/util.h

=======================================
--- /trunk/control.c    Mon Sep  6 05:48:55 2010
+++ /trunk/control.c    Fri Sep 24 09:13:19 2010
@@ -119,7 +119,7 @@

   /* Send request */
   auth = Util_getBasicAuthHeaderMonit();
-  svc = Util_urlEncode((char *)S);
+  svc = Util_encodeServiceName((char *)S);
   if (socket_print(s,
         "POST /%s HTTP/1.0\r\n"
         "Content-Type: application/x-www-form-urlencoded\r\n"
=======================================
--- /trunk/http/cervlet.c       Wed Sep 15 05:36:51 2010
+++ /trunk/http/cervlet.c       Fri Sep 24 09:13:19 2010
@@ -720,7 +720,7 @@

   ASSERT(s);

-  svc = Util_urlEncode(s->name);
+  svc = Util_encodeServiceName(s->name);
   HEAD(svc, s->name, Run.polltime)
   FREE(svc);

@@ -880,7 +880,7 @@

 static void do_home_system(HttpRequest req, HttpResponse res) {
   Service_T s = Run.system;
-  char *svc = Util_urlEncode(s->name);
+  char *svc = Util_encodeServiceName(s->name);
   char *status = get_service_status_html(s);

   out_print(res,
@@ -971,7 +971,7 @@
     }

     status= get_service_status_html(s);
-    svc = Util_urlEncode(s->name);
+    svc = Util_encodeServiceName(s->name);
     out_print(res,
       "<tr %s>"
       "<td width=\"20%%\"><a href='%s'>%s</a></td>"
@@ -1053,7 +1053,7 @@
     }

     status= get_service_status_html(s);
-    svc = Util_urlEncode(s->name);
+    svc = Util_encodeServiceName(s->name);
     out_print(res,
       "<tr %s>"
       "<td width=\"20%%\"><a href='%s'>%s</a></td>"
@@ -1136,7 +1136,7 @@
     }

     status= get_service_status_html(s);
-    svc = Util_urlEncode(s->name);
+    svc = Util_encodeServiceName(s->name);
     out_print(res,
       "<tr %s>"
       "<td width=\"20%%\"><a href='%s'>%s</a></td>"
@@ -1211,7 +1211,7 @@
     }

     status= get_service_status_html(s);
-    svc = Util_urlEncode(s->name);
+    svc = Util_encodeServiceName(s->name);
     out_print(res,
       "<tr %s>"
       "<td width=\"20%%\"><a href='%s'>%s</a></td>"
@@ -1283,7 +1283,7 @@
     }

     status= get_service_status_html(s);
-    svc = Util_urlEncode(s->name);
+    svc = Util_encodeServiceName(s->name);
     out_print(res,
       "<tr %s>"
       "<td width=\"20%%\"><a href='%s'>%s</a></td>"
@@ -1355,7 +1355,7 @@
     }

     status= get_service_status_html(s);
-    svc = Util_urlEncode(s->name);
+    svc = Util_encodeServiceName(s->name);
     out_print(res,
       "<tr %s>"
       "<td width=\"20%%\"><a href='%s'>%s</a></td>"
@@ -1498,7 +1498,7 @@
     return;
   }

-  svc = Util_urlEncode(s->name);
+  svc = Util_encodeServiceName(s->name);

   out_print(res, "<table cellspacing=16><tr nowrap><td><font size=+1>");
   /* Start program */
=======================================
--- /trunk/l.l  Mon Sep 20 14:15:39 2010
+++ /trunk/l.l  Fri Sep 24 09:13:19 2010
@@ -595,7 +595,7 @@
                   }

   [/][^?#\r\n ]*  {
-                     yylval.url->path= xstrdup(yytext);
+                     yylval.url->path= Util_urlEncode(yytext);
                   }

   [?][^#\r\n ]*   {
=======================================
--- /trunk/protocols/http.c     Fri Jan  8 03:20:43 2010
+++ /trunk/protocols/http.c     Fri Sep 24 09:13:19 2010
@@ -120,7 +120,7 @@
   ASSERT(P);

   request= P->request?P->request:"/";
-
+
   Util_getHTTPHostHeader(s, host, STRLEN);
   hostheader= P->request_hostheader?P->request_hostheader:host;

=======================================
--- /trunk/util.c       Fri Sep 24 07:38:19 2010
+++ /trunk/util.c       Fri Sep 24 09:13:19 2010
@@ -1536,6 +1536,16 @@
   url[x]= 0;
   return url;
 }
+
+
+char *Util_encodeServiceName(char *name) {
+        int i;
+        ASSERT(name);
+        char *s = Util_urlEncode(name);
+        for (i = 0; s[i]; i++)
+                if (s[i] == '/') return Util_replaceString(&s, "/", "%2F");
+        return s;
+}


 /**
=======================================
--- /trunk/util.h       Mon Jul 26 07:54:50 2010
+++ /trunk/util.h       Fri Sep 24 09:13:19 2010
@@ -311,6 +311,16 @@
 char *Util_urlDecode(char *url);


+/**
+ * URL escape a service name so it can be safely transfeered over HTTP. In
+ * particular any '/' chars in name is encoded. The caller must free the
+ * returned string.
+ * @param name a service name string to be URL encoded
+ * @return the escaped string
+ */
+char *Util_encodeServiceName(char *name);
+
+
 /**
  * @return a Basic Authentication Authorization string (RFC 2617),
* with credentials from the Run object, NULL if credentials are not defined.



reply via email to

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