Commit Graph

35 Commits (070e109c1413d28b54eb6123a9fd24ac98897554)

Author SHA1 Message Date
Julius Plenz 0a799424f6 fix two encoding bugs
reencode() takes three arguments in the order (txt, from, to), opposed to
reencode_string, which will, like iconv, handle the arguments with from
and to swapped. Fix that (this makes reencode more intuitive).
If src and dst encoding are equivalent, don't do any encoding.

If no special encoding parameter is found within the commit, assume
UTF-8 and explicitly convert to PAGE_ENCODING. The change to reencode()
mentioned above avoids re-encoding a UTF-8 string to UTF-8, for example.

Signed-off-by: Julius Plenz <plenz@cis.fu-berlin.de>
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
13 years ago
Rémi Lagacé 73ac0fb6f2 Reencode author and committer
When a commit has a specific encoding, this encoding also applies to
the author and committer name and email.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
14 years ago
Lars Hjemli 14b4e108a7 parsing.c: enable builds with NO_ICONV defined
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
16 years ago
Lars Hjemli a8305a9543 parsing.c: be prepared for unexpected content in commit/tag objects
When parsing commits and tags cgit made too many assumptions about the
formatting of said objects. This patch tries to make the code be more
prepared to handle 'malformed' objects.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
16 years ago
Lars Hjemli e87e896333 Move cgit_parse_query() from parsing.c to html.c as http_parse_querystring()
This is a generic http-function.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
16 years ago
Lars Hjemli 20a33548b9 Move function for configfile parsing into configfile.[ch]
This is a generic function which wanted its own little object file.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
16 years ago
Lars Hjemli e0e4478e7b Add command dispatcher
This simplifies the code in cgit.c and makes it easier to extend cgit with
new pages/commands.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
16 years ago
Lars Hjemli d1f3bbe9d2 Move cgit_repo into cgit_context
This removes the global variable which is used to keep track of the
currently selected repository, and adds a new variable in the cgit_context
structure.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
16 years ago
Lars Hjemli d14d77fe95 Introduce struct cgit_context
This struct will hold all the cgit runtime information currently found in
a multitude of global variables.

The first cleanup removes all querystring-related variables.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
16 years ago
Lars Hjemli dabb34af76 Merge branch 'stable'
* stable:
  Handle missing timestamp in commit/tag objects
  Set commit date on snapshot contents
17 years ago
Lars Hjemli fc4c4ba3a9 Handle missing timestamp in commit/tag objects
When a commit or tag lacks author/committer/tagger timestamp, do not skip
the next line in the commit/tag object.

Also, do not bother to print timestamps with value 0 as it is close to certain
to be bogus.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
17 years ago
Lars Hjemli a2ebbd6948 Use utf8::reencode_string from git
This replaces the iconv-support in cgit with similar functions already
existing in git.

Signed-off-by: Lars Hjemli <hjemli@gmai.com>
17 years ago
Jonathan Bastien-Filiatrault 7858a309d7 Convert subject and message with iconv_msg. 17 years ago
Jonathan Bastien-Filiatrault af08198304 Add iconv_msg function. 17 years ago
Jonathan Bastien-Filiatrault aa5cc328f4 Set msg_encoding according to the header. 17 years ago
Jonathan Bastien-Filiatrault 3845e177e4 Add commit->msg_encoding, allocate msg dynamicly. 17 years ago
Lars Hjemli c61360fea0 cgit_parse_commit(): Add missing call to xstrdup()
It's rather silly to point into random memory-locations. Also, remove a
call to strdup() used on a literal char *.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
17 years ago
Lars Hjemli 13d2b0b25c Skip unknown header fields when parsing tags and commits
Both the commit- and tagparser failed to handle unexpected header fields.
This adds futureproofing by simply skipping any header we don't know/care
about.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
17 years ago
Lars Hjemli 382805ee83 Add trim_end() and use it to remove trailing slashes from repo paths
The new function removes all trailing instances of an arbitrary character
from a copy of the supplied char array. This is then used to remove any
trailing slashes from cgit_query_path.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
17 years ago
Ondrej Jirman 6130231ed5 Check for NULL commit buffer in cgit_parse_commit()
This can be NULL, so try not to segfault.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
17 years ago
Ondrej Jirman 3ce6fc16ef Handle single-line and empty commit subjects
If commit object ends with \0 after subject line, then info->subject
was not set.

This commit fixes this and also sets subject to ** empty ** if it
would otherwise be empty, so that there is something to click on.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
17 years ago
Lars Hjemli 3de63b264c Don't be fooled by trailing '/' in url-parameter
cgit_parse_url() didn't check if the path-part of urls contained a
real path or just a trailing slash. This made the log-page die since
the path filtering supplied an invalid path argument. This fixes it.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
17 years ago
Lars Hjemli 30ccdcaa74 Enable url=value querystring parameter
This makes is possible to use repo-urls like '/pub/scm/git/git.git' and
even add path specifications, like '/pub/scm/git/git.git/log/documentation'.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
17 years ago
Lars Hjemli 47a81c77fd Restrict deep nesting of configfiles
There is no point in restricting the number of included config-
files, but there is a point in restricting the nestinglevel
of configfiles: to avoid recursive inclusions. This is easily
achieved by decrementing the static nesting-variable upon exit
from cgit_read_config().

Also fix some whitespace breakage.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
17 years ago
Lars Hjemli 5ec6e02bd1 Add include-parameter to config files
This parameter can be used to include another config-file, like
a standalone repository listing.

Suggested in a patch by Kristian Høgsberg <krh@bitplanet.net>

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
17 years ago
Lars Hjemli 61c3ca978c Update to libgit 1.5.2-rc2
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
17 years ago
Lars Hjemli ebd7b0fbc3 Do not die if tag has no message
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
18 years ago
Lars Hjemli a69061fdb7 Add function cgit_parse_tag()
Teach cgit how to extract author info from a tag.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
18 years ago
Lars Hjemli 66091f934a Handle empty/malformed commit messages
An empty commit message would trigger a segfault in the current
cgit_parse_commit().

Also, make sure that all char-pointers are properly initialized.
18 years ago
Lars Hjemli 52e605caf5 Handle %xx encoding in querystring
Convert valid %xx expressions in querystring to ascii, ignore invalid
expressions (i.e. eat the three characters %xx).

Signed-off-by: Lars Hjemli <larsh@hal-2004.(none)>
18 years ago
Lars Hjemli 05b13194b4 Handle '+' in querystring
Translate '+' to ' ' in querystring parser (still doesn't handle %xx)

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
18 years ago
Lars Hjemli 77078ba716 Teach commit parser about author/committer email + timestamp
We want all four of these when showing a commit, so save them in the
commitinfo struct.

Btw: There's probably no good reason to save committer timestamp since
it's already available in commit->date. But it doesn't hurt us either,
and it makes the parser look more complete, so we just do it.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
18 years ago
Lars Hjemli 9a8f88658d Add ui-commit.c + misc ui cleanups
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
18 years ago
Lars Hjemli 2101e26fd6 Add a common commit parser
Make a better commit parser, replacing the ugly one in ui-log.c

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
18 years ago
Lars Hjemli 51ada4fda2 Rename config.c to parsing.c + move cgit_parse_query from cgit.c to parsing.c
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
18 years ago