aboutsummaryrefslogtreecommitdiffstats
path: root/bonus/git.cgi
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2024-03-29 16:32:04 +0100
committerbptato <nincsnevem662@gmail.com>2024-03-29 16:57:16 +0100
commit75a5bdedbe3299b4a8d58239fd6d4ddaf52c8e5b (patch)
treeb2ac338e388eb4df165fd0332e3489f388c0a82d /bonus/git.cgi
parent9053a9096bfe7845b712989ebfa3b9cba28cd3d5 (diff)
downloadchawan-75a5bdedbe3299b4a8d58239fd6d4ddaf52c8e5b.tar.gz
ansi2html: support passing titles
Use content type attributes so e.g. git.cgi can set the title even with a text/x-ansi content type. (This commit also fixes some bugs in content type attribute handling.)
Diffstat (limited to 'bonus/git.cgi')
-rwxr-xr-xbonus/git.cgi13
1 files changed, 5 insertions, 8 deletions
diff --git a/bonus/git.cgi b/bonus/git.cgi
index 1f93862a..387f3a64 100755
--- a/bonus/git.cgi
+++ b/bonus/git.cgi
@@ -27,12 +27,7 @@ for (const p of std.getenv("QUERY_STRING").split('&')) {
}
function startGitCmd(config, params) {
- const titleParams = params.join(' ').replace(/[&<>]/g,
- x => ({'&': '&amp', '<': '&lt', '>': '&gt'}[x]));
- std.out.puts(`Content-Type: text/html
-
-<!DOCTYPE html>
-<title>git ${titleParams}</title>`);
+ std.out.puts("Content-Type: text/html\n\n");
std.out.flush();
const [read_fd, write_fd] = os.pipe();
const [read_fd2, write_fd2] = os.pipe();
@@ -43,7 +38,8 @@ function startGitCmd(config, params) {
os.close(write_fd);
const libexecDir = std.getenv("CHA_LIBEXEC_DIR") ??
'/usr/local/libexec/chawan';
- os.exec([libexecDir + "/ansi2html"], {
+ const title = encodeURIComponent('git ' + params.join(' '));
+ os.exec([libexecDir + "/ansi2html", "-st", title], {
stdin: read_fd,
stdout: write_fd2,
block: false
@@ -78,7 +74,8 @@ if (params[0] == "log") {
}
f.close();
} else {
- std.out.puts("Content-Type: text/x-ansi\n\n");
+ const title = encodeURIComponent('git ' + params.join(' '));
+ std.out.puts(`Content-Type: text/x-ansi;title=${title}\n\n`);
std.out.flush();
const pid = os.exec(["git", ...config, ...params], {
block: false,