Skip to content
Browse files

from trunk; evhttp fixes:

 - do not uridecode request uri
 - escape &
 - remove O(n^2) from htmlescape



svn:r334
  • Loading branch information...
1 parent 23b0a2a commit d2263df2255a972f91923b1c636917bb9d86dace @provos provos committed Feb 18, 2007
Showing with 6 additions and 6 deletions.
  1. +1 −1 configure.in
  2. +5 −5 http.c
View
2 configure.in
@@ -1,7 +1,7 @@
dnl configure.in for libevent
AC_INIT(event.c)
-AM_INIT_AUTOMAKE(libevent,1.3)
+AM_INIT_AUTOMAKE(libevent,1.3a)
AM_CONFIG_HEADER(config.h)
AM_MAINTAINER_MODE
View
10 http.c
@@ -204,16 +204,16 @@ html_replace(char ch)
char *
evhttp_htmlescape(const char *html)
{
- int i, new_size = 0;
+ int i, new_size = 0, old_size = strlen(html);
char *escaped_html, *p;
- for (i = 0; i < strlen(html); ++i)
+ for (i = 0; i < old_size; ++i)
new_size += strlen(html_replace(html[i]));
p = escaped_html = malloc(new_size + 1);
if (escaped_html == NULL)
event_err(1, "%s: malloc(%d)", __func__, new_size + 1);
- for (i = 0; i < strlen(html); ++i) {
+ for (i = 0; i < old_size; ++i) {
const char *replaced = html_replace(html[i]);
/* this is length checked */
strcpy(p, replaced);
@@ -1046,7 +1046,7 @@ evhttp_parse_request_line(struct evhttp_request *req, char *line)
return (-1);
}
- if ((req->uri = evhttp_decode_uri(uri)) == NULL) {
+ if ((req->uri = strdup(uri)) == NULL) {
event_warn("%s: evhttp_decode_uri", __func__);
return (-1);
}
@@ -1675,7 +1675,7 @@ evhttp_send_page(struct evhttp_request *req, struct evbuffer *databuf)
static const char uri_chars[256] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0,
/* 64 */
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,

0 comments on commit d2263df

Please sign in to comment.
Something went wrong with that request. Please try again.