AgeCommit message (Collapse)AuthorLines
Show characters a browser breaks at as escapesBryce Kwon-0/+79
The HTML parser turns a carriage return with no line feed after it into a line feed, and WebKit starts a new line at U+2028 and U+2029, while git and the line numbers count line feeds alone, so each one set every later line of the tree and blame pages a line below its number. CSS Text makes vertical tab, form feed and next line forced breaks as well, though no engine honours that yet. The escapes follow gitweb, which shows control characters the same way.
Keep every control byte out of a header valueBryce Kwon-0/+4
A quoted header value escaped only the quote, the backslash, CR and LF. A web server refuses a response whose header holds any other control byte, so a file named with one could not be downloaded at all.
Cut text between characters, never inside oneBryce Kwon-0/+6
The index description was cut at a byte count, which could split a multibyte character and leave an invalid sequence on the page. Commit subjects already backed up to the start of the character, so html_ntxt now does that for every caller.
Encode repository urls and the feed branchBryce Kwon-0/+12
Links built from the repository url, among them the description link on the index and the Atom and refs links, wrote it as configured, so a name holding a space, '#' or '?' broke them. The feed link in the page head did the same with the branch, which turned a '+' into a space.
Read and write slot keys and pages in fullBryce Kwon-1/+5
xread and xwrite may move fewer bytes than asked. A short write of the key left a slot that could never match, a short read of it reported a collision, and a page write that moved nothing looped for ever.
Keep the error of a request that dies mid captureBryce Kwon-0/+1
The commit and diff pages collect each file's body before printing it, and a die in git while one was collected wrote the error page into that body, which was never sent, so the visitor got a page cut off mid table.
End a request quietly when the client has goneBryce Kwon-2/+18
A write that failed with EPIPE on an uncached page died into an error page, which died again at exit when the page could not be sent either, and git logged a recursion warning on every dropped connection. A filter that exits early fails a write the same way, so the quiet exit is kept for writes that reach the client itself.
Keep the query string across the about redirectsBryce Kwon-0/+22
The hop to the trailing-slash form of the about page, and the hop back to the summary of a repository without a readme, were built from the path alone, so a request for the about page of another branch landed on the default one. The query goes into the Location line as the client sent it, with any byte a header cannot carry percent-encoded.
Harden the request path, scan and error recoveryBryce Kwon-4/+28
Read every query parameterBryce Kwon-1/+3
A parameter without a value swallowed the parameter after it.
Clean up the whole treeBryce Kwon-10/+5
Trim the comments and dead code across the treeBryce Kwon-12/+10
Log scan lock failures that are not contentionBryce Kwon-2/+2
Drop the XHTML slashes and boolean spellingsBryce Kwon-4/+4
Fix ampersand handling in generated urlsBryce Kwon-24/+26
Restyle the sources and fix the audit's findingsBryce Kwon-141/+136
Render each diff body while its file is openBryce Kwon-0/+27
Gather page output into one bufferBryce Kwon-2/+45
Settle the names, types and layout of the sourcesBryce Kwon-3/+3
Point the fork's links and credits at itselfBryce Kwon-1/+1
AUTHORS now records the upstream developers as the project's history rather than as maintainers of the fork.
Reorganize into source, assets and librariesBryce Kwon-0/+0
The C sources move to source/, the served files to assets/, the bundled Git submodule to libraries/git and the filter scripts to extensions/. Everything the build generates now lands in build/, so a clean is a single remove and the tree stays clean.
html: fix handling of null bytePeter Prohaska-1/+1
A return value of `len` or more means that the output was truncated. Signed-off-by: Peter Prohaska <pitrp@web.de> Signed-off-by: Christian Hesse <mail@eworm.de>
html: html_ntxt with no ellipsisJeff Smith-21/+11
For implementing a ui-blame page, there is need for a function that outputs a selection from a block of text, transformed for HTML output, but with no further modifications or additions. Signed-off-by: Jeff Smith <whydoubt@gmail.com> Reviewed-by: John Keeping <john@keeping.me.uk>
Simplify http_parse_querystring()Lukas Fleischer-56/+10
Instead of reimplementing URL parameter parsing from scratch, use url_decode_parameter_name() and url_decode_parameter_value() which are already provided by Git. Also, change the return type of http_parse_querystring() to void since its only caller already ignores the return value. Signed-off-by: Lukas Fleischer <lfleischer@lfos.de>
ui-shared: prevent malicious filename from injecting headersJason A. Donenfeld-0/+26
html: remove html_status()John Keeping-7/+0
This is now unused. Signed-off-by: John Keeping <john@keeping.me.uk>
Remove redundant includesJohn Keeping-6/+0
These are all included in git-compat-util.h (when necessary), which we include in cgit.h. Signed-off-by: John Keeping <john@keeping.me.uk>
html: avoid using a plain integer as a NULL pointerJohn Keeping-22/+32
Sparse complains about this table because we use the integer zero as the NULL pointer. Use this as an opportunity to reformat the table so that it always contains 8 elements per row, making it easier to see which values are being set and which are not. Signed-off-by: John Keeping <john@keeping.me.uk>
html: remove redundant htmlfd variableJohn Keeping-3/+1
This is never changed from STDOUT_FILENO, so just use that value directly. Signed-off-by: John Keeping <john@keeping.me.uk>
Update copyright informationLukas Fleischer-1/+1
* Name "cgit Development Team" as copyright holder to avoid listing every single developer. * Update copyright ranges. Signed-off-by: Lukas Fleischer <cgit@crytocrack.de>
html.c: die when write failsJohn Keeping-1/+1
If we fail to write HTML output once, there's no point carrying on so just write a failure message once and die. By using Git's die_errno function we also let the user know in what way the write failed. Signed-off-by: John Keeping <john@keeping.me.uk>
html.c: add various strbuf and varadic helpersJohn Keeping-3/+50
This adds the fmtalloc helper, html_txtf, html_vtxtf, and html_attrf. These takes a printf style format string like htmlf but escapes the resulting string. The html_vtxtf variant takes a va_list whereas html_txtf is variadic. Signed-off-by: John Keeping <john@keeping.me.uk>
html.c: Replace strdup() with xstrdup()Lukas Fleischer-5/+2
Use the xstrdup() wrapper which already bails out if strdup() returns a NULL pointer. Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
Always #include corresponding .h in .c filesJohn Keeping-0/+1
While doing this, remove declarations from header files where the corresponding definition is declared "static" in order to avoid build errors. Also re-order existing headers in ui-*.c so that the file-specific header always comes immediately after "cgit.h", helping with future consistency. Signed-off-by: John Keeping <john@keeping.me.uk>
html: check return value of writeJason A. Donenfeld-2/+3
This squelches a gcc warning. It's also correct that we check to see if there are any partial or failed writes. For now, we just print a warning to stderr. In the future, perhaps it will prove wise to exit(1) on partial writes.
Mark several functions/variables staticLukas Fleischer-3/+3
Spotted by parsing the output of `gcc -Wmissing-prototypes [...]`. Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
White space around control verbs.Jason A. Donenfeld-7/+7
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Fix several whitespace errorsLukas Fleischer-39/+39
* Remove whitespace at the end of lines. * Replace space indentation by tabs. * Add whitespace before/after several operators ("+", "-", "*", ...) * Add whitespace to assignments ("foo = bar;"). * Fix whitespace in parameter lists ("foobar(foo, bar, 42)"). Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
html.c: avoid out-of-bounds access for url_escape_tableEric Wong-2/+2
This fixes a segfault for me with with -O2 optimization on x86 with gcc (Debian 4.4.5-8) 4.4.5 I can reliably reproduce it with the following parameters when pointed to the git.git repository: PATH_INFO='/git-core.git/diff/' QUERY_STRING='id=2b93bfac0f5bcabbf60f174f4e7bfa9e318e64d5&id2=d6da71a9d16b8cf27f9d8f90692d3625c849cbc8' Signed-off-by: Eric Wong <normalperson@yhbt.net> Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Properly escape ampersands inside HTML attributesLukas Fleischer-1/+3
Ampersands ("&") appearing inside HTML attributes need to be translated to "&amp;". Otherwise, invalid XHTML will be generated at various places, such as at tree views containing links to submodules. Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de> Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Fix memory leak in http_parse_querystring().Lukas Fleischer-2/+3
Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de> Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Fix escaping of paths with spacesJonathon Mah-4/+6
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
html.c: add html_intoption()Lars Hjemli-0/+8
This is similar to html_option, but for int values. Signed-off-by: Lars Hjemli <hjemli@gmail.com>
do not infloop on a query ending in %XY, for invalid hex X or YJim Meyering-1/+1
When a query ends in say %gg, (or any invalid hex) e.g., http://git.gnome.org/browse/gdlmm/commit/?id=%gg convert_query_hexchar calls memmove(txt, txt+3, 0), and then returns txt-1, so the loop in http_parse_querystring never terminates. The solution is to make the memmove also copy the trailing NUL. * html.c (convert_query_hexchar): Fix off-by-one error. Signed-off-by: Lars Hjemli <hjemli@gmail.com>
html.c: use '+' to escape spaces in urlsLars Hjemli-2/+2
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
prefer html_raw() to write()Mark Lodato-9/+9
To make the code more consistent, and to not rely on the implementation of html(), always use html_raw(...) instead of write(htmlfd, ...). Signed-off-by: Mark Lodato <lodatom@gmail.com>
html: fix strcpy bug in convert_query_hexcharMark Lodato-4/+5
The source and destination strings in strcpy() may not overlap. Instead, use memmove(), which allows overlap. This fixes test t0104, where 'url=foo%2bbar/tree' was being parsed improperly. Signed-off-by: Mark Lodato <lodatom@gmail.com>
html: properly percent-escape URLsMark Lodato-4/+32
The only valid characters for a URL are unreserved characters a-zA-Z0-9_-.~ and the reserved characters !*'();:@&=+$,/?%#[] , as per RFC 3986. Everything else must be escaped. Additionally, the # and ? always have special meaning, and the &, =, and + have special meaning in a query string, so they too must be escaped. To make this easier, a table of escapes is now used so that we do not have to call fmt() for each character; if the entry is 0, no escaping is needed. Signed-off-by: Mark Lodato <lodatom@gmail.com>
html: make all strings 'const char *'Mark Lodato-17/+17
None of the html_* functions modify their argument, so they can all be 'const char *' instead of a simple 'char *'. This removes the need to cast (or copy) when trying to print a const string. Signed-off-by: Mark Lodato <lodatom@gmail.com>
html.c: use correct escaping in html attributesLars Hjemli-2/+4
First, an apostrophe is not a quote. Second, we also need to escape quotes. And finally, quotes are encoded as '&quot;', not '&quote;'. Sighned-off-by: Lars Hjemli <hjemli@gmail.com>