Commit Diff


commit - d81f9039e7f1d004b3b87dd48c1e787c97ff5a31
commit + f1200fe3a020b8b790beb340db7334e07faf9f5d
blob - 12819268eddbfa9b3a5d68d8897c937bb20f7cd4
blob + 52b2cb624d22803080950f1af69d72ea818f9fd8
--- gotweb/files/cgi-bin/gw_tmpl/err.tmpl
+++ gotweb/files/cgi-bin/gw_tmpl/err.tmpl
@@ -14,7 +14,12 @@
 			@@search@@
 		</div>
 		<div id="content">
-			@@content@@
+			<div id='err_title_wrapper'>
+				<div id='err_title'>Error</div>
+			</div>
+			<div id='err_content'>
+				@@content@@
+			</div>
 		</div>
 		@@siteowner@@
 	</div>
blob - dd8d35ab41ec0d66aec6dcf0683a8cedfac9f562
blob + 33a8c27a825a76a8127cf4d6e3ffa038c1220278
--- gotweb/files/htdocs/gotweb/gotweb.css
+++ gotweb/files/htdocs/gotweb/gotweb.css
@@ -362,7 +362,30 @@ body {
 	padding-top: 5px;
 	padding-bottom: 5px;
 }
+
+/* err.tmpl */
 
+#err_title_wrapper {
+	clear: left;
+	float: left;
+	width: 100%;
+	background-color: LightSlateGray;
+	color: #ffffff;
+}
+#err_title {
+	padding-left: 10px;
+	padding-top: 5px;
+	padding-bottom: 5px;
+}
+#err_content {
+	clear: left;
+	float: left;
+	width: 100%;
+	padding-left: 20px;
+	padding-top: 20px;
+	padding-bottom: 20px;
+}
+
 /* briefs.tmpl */
 
 #briefs_title_wrapper {
blob - 97d12fc165a7c18166f39eaf45f4bc723c3830b6
blob + 4db052de35e4494fe8f58c9beeaea06e365e346b
--- gotweb/gotweb.c
+++ gotweb/gotweb.c
@@ -60,6 +60,7 @@ struct gw_trans {
 	struct ktemplate	*gw_tmpl;
 	struct khtmlreq		*gw_html_req;
 	struct kreq		*gw_req;
+	const struct got_error	*error;
 	const char		*repo_name;
 	char			*repo_path;
 	char			*commit;
@@ -152,15 +153,14 @@ static const struct kvalid gw_keys[KEY__ZMAX] = {
 	{ kvalid_stringne,	"path" },
 };
 
-static const struct got_error	*gw_init_gw_dir(struct gw_dir **, const char *);
 static struct gw_header		*gw_init_header(void);
 
 static void			 gw_free_headers(struct gw_header *);
-static void			 gw_display_error(struct gw_trans *,
-				    const struct got_error *);
 
 static int			 gw_template(size_t, void *);
 
+static const struct got_error	*gw_error(struct gw_trans *);
+static const struct got_error	*gw_init_gw_dir(struct gw_dir **, const char *);
 static const struct got_error	*gw_get_repo_description(char **,
 				    struct gw_trans *, char *);
 static const struct got_error	*gw_get_repo_owner(char **, struct gw_trans *,
@@ -246,7 +246,7 @@ static struct gw_query_action gw_query_funcs[] = {
 	{ GW_BRIEFS,	"briefs",	gw_briefs,	"gw_tmpl/briefs.tmpl" },
 	{ GW_COMMITS,	"commits",	gw_commits,	"gw_tmpl/commit.tmpl" },
 	{ GW_DIFF,	"diff",		gw_diff,	"gw_tmpl/diff.tmpl" },
-	{ GW_ERR,	 NULL,		NULL,		"gw_tmpl/err.tmpl" },
+	{ GW_ERR,	"error",	gw_error,	"gw_tmpl/err.tmpl" },
 	{ GW_INDEX,	"index",	gw_index,	"gw_tmpl/index.tmpl" },
 	{ GW_SUMMARY,	"summary",	gw_summary,	"gw_tmpl/summry.tmpl" },
 	{ GW_TAG,	"tag",		gw_tag,		"gw_tmpl/tag.tmpl" },
@@ -1637,16 +1637,22 @@ gw_parse_querystring(struct gw_trans *gw_trans)
 			return got_error_from_errno("asprintf");
 
 		/* get action and set function */
-		if ((p = gw_trans->gw_req->fieldmap[KEY_ACTION]))
+		if ((p = gw_trans->gw_req->fieldmap[KEY_ACTION])) {
 			for (i = 0; i < nitems(gw_query_funcs); i++) {
 				action = &gw_query_funcs[i];
-				if (action->func_name == NULL ||
-				    strcmp(action->func_name, p->parsed.s))
+				if (action->func_name == NULL)
 					continue;
-
-				gw_trans->action = i;
-				break;
+				if (strcmp(action->func_name,
+				    p->parsed.s) == 0) {
+					gw_trans->action = i;
+					break;
+				}
 			}
+			if (gw_trans->action == -1) {
+				gw_trans->action = GW_ERR;
+				gw_trans->error = got_error_from_errno("bad action");
+			}
+		}
 
  		if ((p = gw_trans->gw_req->fieldmap[KEY_COMMIT_ID])) {
 			if (asprintf(&gw_trans->commit, "%s",
@@ -1669,10 +1675,6 @@ gw_parse_querystring(struct gw_trans *gw_trans)
 				return got_error_from_errno("asprintf");
 		}
 
-		if (action == NULL) {
-			error = got_error_from_errno("invalid action");
-			return error;
-		}
 		error = gw_init_gw_dir(&gw_trans->gw_dir, gw_trans->repo_name);
 		if (error)
 			return error;
@@ -1775,16 +1777,14 @@ gw_display_index(struct gw_trans *gw_trans)
 	return gw_kcgi_error(khtml_close(gw_trans->gw_html_req));
 }
 
-static void
-gw_display_error(struct gw_trans *gw_trans, const struct got_error *err)
+static const struct got_error *
+gw_error(struct gw_trans *gw_trans)
 {
-	if (gw_display_open(gw_trans, KHTTP_200, gw_trans->mime) != NULL)
-		return;
+	enum kcgi_err kerr;
 
-	if (khtml_open(gw_trans->gw_html_req, gw_trans->gw_req, 0) != KCGI_OK)
-		return;
-	khtml_puts(gw_trans->gw_html_req, err->msg);
-	khtml_close(gw_trans->gw_html_req);
+	kerr = khtml_puts(gw_trans->gw_html_req, gw_trans->error->msg);
+
+	return gw_kcgi_error(kerr);
 }
 
 static int
@@ -3108,6 +3108,8 @@ gw_get_commit(struct gw_trans *gw_trans, struct gw_hea
 		free(s);
 	}
 
+	free(refs_str);
+
 	error = got_object_id_str(&header->commit_id, header->id);
 	if (error)
 		return error;
@@ -4246,6 +4248,7 @@ main(int argc, char *argv[])
 	TAILQ_INIT(&gw_trans->gw_dirs);
 	TAILQ_INIT(&gw_trans->gw_headers);
 
+	gw_trans->action = -1;
 	gw_trans->page = 0;
 	gw_trans->repos_total = 0;
 	gw_trans->repo_path = NULL;
@@ -4273,11 +4276,6 @@ main(int argc, char *argv[])
 	else
 		error = gw_display_index(gw_trans);
 done:
-	if (error) {
-		gw_trans->mime = KMIME_TEXT_PLAIN;
-		gw_trans->action = GW_ERR;
-		gw_display_error(gw_trans, error);
-	}
 	if (gw_malloc) {
 		free(gw_trans->gw_conf->got_repos_path);
 		free(gw_trans->gw_conf->got_site_name);