html escape characters in blame lines
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
diff --git a/gotweb/gotweb.c b/gotweb/gotweb.c
index b48c564..b97f4ea 100644
--- a/gotweb/gotweb.c
+++ b/gotweb/gotweb.c
@@ -187,9 +187,9 @@ static const struct got_error* apply_unveil(const char *, const char *);
static const struct got_error* cmp_tags(void *, int *,
struct got_reference *,
struct got_reference *);
-static const struct got_error* resolve_commit_arg(struct got_object_id **,
+static const struct got_error* resolve_commit_arg(struct got_object_id **,
const char *, struct got_repository *);
-static const struct got_error* match_object_id(struct got_object_id **,
+static const struct got_error* match_object_id(struct got_object_id **,
char **, const char *r, int, int,
struct got_repository *);
static const struct got_error* blame_cb(void *, int, int,
@@ -2347,7 +2347,8 @@ blame_cb(void *arg, int nlines, int lineno, struct got_object_id *id)
}
while (bline->annotated) {
- char *smallerthan, *at, *nl, *committer, *blame_row = NULL;
+ char *smallerthan, *at, *nl, *committer, *blame_row = NULL,
+ *line_escape = NULL;
size_t len;
if (getline(&line, &linesize, a->f) == -1) {
@@ -2370,15 +2371,22 @@ blame_cb(void *arg, int nlines, int lineno, struct got_object_id *id)
nl = strchr(line, '\n');
if (nl)
*nl = '\0';
+
+ if (strcmp(line, "") != 0)
+ line_escape = strdup(gw_html_escape(line));
+ else
+ line_escape = strdup("");
+
asprintf(&blame_row, log_blame_line, a->nlines_prec,
a->lineno_cur, bline->id_str, bline->datebuf, committer,
- line);
+ line_escape);
a->lineno_cur++;
err = buf_puts(&newsize, a->blamebuf, blame_row);
if (err)
return err;
bline = &a->lines[a->lineno_cur - 1];
+ free(line_escape);
free(blame_row);
}
done: