commit - a097512813331d3a6c5eac85579b195a9707f114
commit + 78a9dab553fece83d11427c457b67285d7e8e81c
blob - 6618bbe2199713860567936a71131c70b68ab94b
blob + f79e068133c2fb0e06f9ae5ba4ef810901402831
--- gotweb/files/htdocs/gotweb/gotweb.css
+++ gotweb/files/htdocs/gotweb/gotweb.css
padding-top: 5px;
padding-bottom: 5px;
overflow: auto;
+ white-space: pre-wrap;
}
/* headers */
width: 72%;
padding-top: 2px;
padding-bottom: 2px;
+ white-space: pre-wrap;
}
#header_tree_title {
clear: left;
padding-left: 20px;
padding-top: 20px;
padding-bottom: 20px;
+ white-space: pre-wrap;
}
/* blame.tmpl */
clear: left;
float: left;
margin-top: 25px;
+ white-space: pre-wrap;
}
/* diff.tmpl */
blob - 7912b925a6449234804781bc808a0820647f3eaa
blob + dd8286827356c540ca18fc995b71fe8211596e35
--- gotweb/gotweb.c
+++ gotweb/gotweb.c
static const struct got_error *gw_get_clone_url(char **, struct gw_trans *,
char *);
static char *gw_get_site_link(struct gw_trans *);
-static const struct got_error *gw_html_escape(char **, const char *);
static const struct got_error *gw_colordiff_line(struct gw_trans *, char *);
static const struct got_error *gw_gen_commit_header(struct gw_trans *, char *,
{
const struct got_error *error = NULL;
struct gw_header *header = NULL;
- char *age = NULL, *escaped_commit_msg = NULL;
+ char *age = NULL;
enum kcgi_err kerr;
if (pledge("stdio rpath wpath cpath proc exec sendfd unveil",
error = gw_gen_age_header(gw_trans, age ?age : "");
if (error)
goto done;
- /*
- * XXX: keeping this for now, since kcgihtml does not convert
- * \n into <br /> yet.
- */
- error = gw_html_escape(&escaped_commit_msg, header->commit_msg);
- if (error)
- goto done;
error = gw_gen_commit_msg_header(gw_trans, header->commit_msg);
if (error)
goto done;
done:
got_ref_list_free(&header->refs);
gw_free_headers(header);
- free(escaped_commit_msg);
if (error == NULL && kerr != KCGI_OK)
error = gw_kcgi_error(kerr);
return error;
{
const struct got_error *error = NULL;
struct gw_header *header = NULL;
- char *age = NULL, *escaped_commit_msg = NULL;
+ char *age = NULL;
enum kcgi_err kerr = KCGI_OK;
if (pledge("stdio rpath wpath cpath proc exec sendfd unveil",
if (error)
goto done;
error = gw_gen_age_header(gw_trans, age ?age : "");
- if (error)
- goto done;
- /*
- * XXX: keeping this for now, since kcgihtml does not convert
- * \n into <br /> yet.
- */
- error = gw_html_escape(&escaped_commit_msg, header->commit_msg);
if (error)
goto done;
error = gw_gen_commit_msg_header(gw_trans, header->commit_msg);
got_ref_list_free(&header->refs);
gw_free_headers(header);
free(age);
- free(escaped_commit_msg);
if (error == NULL && kerr != KCGI_OK)
error = gw_kcgi_error(kerr);
return error;
{
const struct got_error *error = NULL;
struct gw_header *header = NULL, *n_header = NULL;
- char *age = NULL, *escaped_commit_msg = NULL;
+ char *age = NULL;
char *href_diff = NULL, *href_blob = NULL;
enum kcgi_err kerr = KCGI_OK;
"commit", KATTR__MAX);
if (kerr != KCGI_OK)
goto done;
- /*
- * XXX: keeping this for now, since kcgihtml does not convert
- * \n into <br /> yet.
- */
- error = gw_html_escape(&escaped_commit_msg,
- n_header->commit_msg);
- if (error)
- goto done;
- kerr = khttp_puts(gw_trans->gw_req, escaped_commit_msg);
+ kerr = khttp_puts(gw_trans->gw_req, n_header->commit_msg);
if (kerr != KCGI_OK)
goto done;
kerr = khtml_closeelem(gw_trans->gw_html_req, 1);
free(age);
age = NULL;
- free(escaped_commit_msg);
- escaped_commit_msg = NULL;
}
done:
got_ref_list_free(&header->refs);
free(age);
free(href_diff);
free(href_blob);
- free(escaped_commit_msg);
if (error == NULL && kerr != KCGI_OK)
error = gw_kcgi_error(kerr);
return error;
const struct got_error *error = NULL;
struct gw_header *header = NULL;
char *tree = NULL, *tree_html = NULL, *tree_html_disp = NULL;
- char *age = NULL, *age_html = NULL, *escaped_commit_msg = NULL;
+ char *age = NULL, *age_html = NULL;
enum kcgi_err kerr;
if (pledge("stdio rpath proc exec sendfd unveil", NULL) == -1)
if (error)
goto done;
error = gw_gen_age_header(gw_trans, age ?age : "");
- if (error)
- goto done;
- /*
- * XXX: keeping this for now, since kcgihtml does not convert
- * \n into <br /> yet.
- */
- error = gw_html_escape(&escaped_commit_msg, header->commit_msg);
if (error)
goto done;
error = gw_gen_commit_msg_header(gw_trans, header->commit_msg);
free(tree);
free(age);
free(age_html);
- free(escaped_commit_msg);
if (error == NULL && kerr != KCGI_OK)
error = gw_kcgi_error(kerr);
return error;
{
const struct got_error *error = NULL;
struct gw_header *header = NULL;
- char *escaped_commit_msg = NULL;
enum kcgi_err kerr;
if (pledge("stdio rpath proc exec sendfd unveil", NULL) == -1)
header->refs_str);
if (error)
goto done;
- /*
- * XXX: keeping this for now, since kcgihtml does not convert
- * \n into <br /> yet.
- */
- error = gw_html_escape(&escaped_commit_msg, header->commit_msg);
- if (error)
- goto done;
error = gw_gen_commit_msg_header(gw_trans, header->commit_msg);
if (error)
goto done;
done:
got_ref_list_free(&header->refs);
gw_free_headers(header);
- free(escaped_commit_msg);
if (error == NULL && kerr != KCGI_OK)
error = gw_kcgi_error(kerr);
return error;
struct got_reflist_head refs;
struct got_reflist_entry *re;
char *age = NULL;
- char *escaped_tag_commit = NULL;
char *id_str = NULL, *refstr = NULL, *newline, *href_commits = NULL;
char *tag_commit0 = NULL, *href_tag = NULL, *href_briefs = NULL;
struct got_tag_object *tag = NULL;
KATTR_ID, "tag_info", KATTR__MAX);
if (kerr != KCGI_OK)
goto done;
- /*
- * XXX: keeping this for now, since kcgihtml does not
- * convert \n into <br /> yet.
- */
- error = gw_html_escape(&escaped_tag_commit, tag_commit);
- if (error)
- goto done;
- kerr = khttp_puts(gw_trans->gw_req, escaped_tag_commit);
+ kerr = khttp_puts(gw_trans->gw_req, tag_commit);
if (kerr != KCGI_OK)
goto done;
break;
refstr = NULL;
free(age);
age = NULL;
- free(escaped_tag_commit);
- escaped_tag_commit = NULL;
free(tag_commit0);
tag_commit0 = NULL;
free(href_tag);
free(id_str);
free(refstr);
free(age);
- free(escaped_tag_commit);
free(tag_commit0);
free(href_tag);
free(href_briefs);
got_object_commit_get_committer(header->commit);
if (error)
return error;
-
- /* XXX Doesn't the log message require escaping? */
error = got_object_commit_get_logmsg(&commit_msg0, header->commit);
if (error)
return error;
"diff_line", KATTR_CLASS, color ? color : "", KATTR__MAX);
if (error == NULL && kerr != KCGI_OK)
error = gw_kcgi_error(kerr);
- return error;
-}
-
-/*
- * XXX This function should not exist.
- * We should let khtml_puts(3) handle HTML escaping.
- */
-static const struct got_error *
-gw_html_escape(char **escaped_html, const char *orig_html)
-{
- const struct got_error *error = NULL;
- struct escape_pair {
- char c;
- const char *s;
- } esc[] = {
- { '>', ">" },
- { '<', "<" },
- { '&', "&" },
- { '"', """ },
- { '\'', "'" },
- { '\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;
}