Commit Diff


commit - ea1b5cf5005faca9f93f85077f7758697a39c622
commit + 11490987f87a21739abbbaba45fa408258cb6581
blob - bff6367b04a8ed87a09a78c9afbc95a0fbea44c5
blob + c479b0af842d734f579e8d5442cc0119c67ba4ed
--- gotwebd/gotweb.c
+++ gotwebd/gotweb.c
@@ -999,70 +999,6 @@ done:
 	}
 	if (d != NULL && closedir(d) == EOF && error == NULL)
 		error = got_error_from_errno("closedir");
-	return error;
-}
-
-const struct got_error *
-gotweb_escape_html(char **escaped_html, const char *orig_html)
-{
-	const struct got_error *error = NULL;
-	struct escape_pair {
-		char c;
-		const char *s;
-	} esc[] = {
-		{ '>', ">" },
-		{ '<', "&lt;" },
-		{ '&', "&amp;" },
-		{ '"', "&quot;" },
-		{ '\'', "&apos;" },
-		{ '\n', "<br />" },
-	};
-	size_t orig_len, len;
-	int i, j, x;
-
-	orig_len = strlen(orig_html);
-	len = orig_len;
-	for (i = 0; i < orig_len; i++) {
-		for (j = 0; j < nitems(esc); j++) {
-			if (orig_html[i] != esc[j].c)
-				continue;
-			len += strlen(esc[j].s) - 1 /* escaped char */;
-		}
-	}
-
-	*escaped_html = calloc(len + 1 /* NUL */, sizeof(**escaped_html));
-	if (*escaped_html == NULL)
-		return got_error_from_errno("calloc");
-
-	x = 0;
-	for (i = 0; i < orig_len; i++) {
-		int escaped = 0;
-		for (j = 0; j < nitems(esc); j++) {
-			if (orig_html[i] != esc[j].c)
-				continue;
-
-			if (strlcat(*escaped_html, esc[j].s, len + 1)
-			    >= len + 1) {
-				error = got_error(GOT_ERR_NO_SPACE);
-				goto done;
-			}
-			x += strlen(esc[j].s);
-			escaped = 1;
-			break;
-		}
-		if (!escaped) {
-			(*escaped_html)[x] = orig_html[i];
-			x++;
-		}
-	}
-done:
-	if (error) {
-		free(*escaped_html);
-		*escaped_html = NULL;
-	} else {
-		(*escaped_html)[x] = '\0';
-	}
-
 	return error;
 }
 
@@ -1276,32 +1212,6 @@ gotweb_render_absolute_url(struct request *c, struct g
 		return -1;
 
 	return gotweb_render_url(c, url);
-}
-
-int
-gotweb_link(struct request *c, struct gotweb_url *url, const char *fmt, ...)
-{
-	va_list ap;
-	int r;
-
-	if (fcgi_printf(c, "<a href='") == -1)
-		return -1;
-
-	if (gotweb_render_url(c, url) == -1)
-		return -1;
-
-	if (fcgi_printf(c, "'>") == -1)
-		return -1;
-
-	va_start(ap, fmt);
-	r = fcgi_vprintf(c, fmt, ap);
-	va_end(ap);
-	if (r == -1)
-		return -1;
-
-	if (fcgi_printf(c, "</a>"))
-		return -1;
-	return 0;
 }
 
 static struct got_repository *
blob - 9a1da08f309eb5fd956f60c275b48bd8c41bbbe0
blob + 8faa234a4738e43f9a19f2abf940e040fc24ebc5
--- gotwebd/gotwebd.h
+++ gotwebd/gotwebd.h
@@ -363,8 +363,8 @@ struct gotwebd {
 };
 
 /*
- * URL parameter for gotweb_link.  NULL values and int set to -1 are
- * implicitly ignored, and string are properly escaped.
+ * URL parameter for gotweb_render_url.  NULL values and int set to -1
+ * are implicitly ignored, and string are properly escaped.
  */
 struct gotweb_url {
 	int		 action;
@@ -460,13 +460,9 @@ void gotweb_get_navs(struct request *, struct gotweb_u
     struct gotweb_url *, int *);
 const struct got_error *gotweb_get_time_str(char **, time_t, int);
 const struct got_error *gotweb_init_transport(struct transport **);
-const struct got_error *gotweb_escape_html(char **, const char *);
 const char *gotweb_action_name(int);
 int gotweb_render_url(struct request *, struct gotweb_url *);
 int gotweb_render_absolute_url(struct request *, struct gotweb_url *);
-int gotweb_link(struct request *, struct gotweb_url *, const char *, ...)
-	__attribute__((__format__(printf, 3, 4)))
-	__attribute__((__nonnull__(3)));
 void gotweb_free_repo_commit(struct repo_commit *);
 void gotweb_free_repo_tag(struct repo_tag *);
 void gotweb_process_request(struct request *);