about summary refs log tree commit diff
path: root/ui-summary.c
diff options
context:
space:
mode:
Diffstat (limited to 'ui-summary.c')
-rw-r--r--ui-summary.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/ui-summary.c b/ui-summary.c
index 2f8a822..57206dd 100644
--- a/ui-summary.c
+++ b/ui-summary.c
@@ -99,6 +99,7 @@ void cgit_print_summary()
 void cgit_parse_readme(const char *readme, const char *path, char **filename, char **ref, struct cgit_repo *repo)
 {
 	const char *slash, *colon;
+	char *resolved_base, *resolved_full;
 
 	*filename = NULL;
 	*ref = NULL;
@@ -133,7 +134,19 @@ void cgit_parse_readme(const char *readme, const char *path, char **filename, ch
 		}
 		*filename = xmalloc(slash - readme + 1 + strlen(path) + 1);
 		strncpy(*filename, readme, slash - readme + 1);
+		if (!(*ref))
+			resolved_base = realpath(*filename, NULL);
 		strcpy(*filename + (slash - readme + 1), path);
+		if (!(*ref))
+			resolved_full = realpath(*filename, NULL);
+		if (!(*ref) && (!resolved_base || !resolved_full || strstr(resolved_full, resolved_base) != resolved_full)) {
+			free(*filename);
+			*filename = NULL;
+		}
+		if (!(*ref)) {
+			free(resolved_base);
+			free(resolved_full);
+		}
 	} else
 		*filename = xstrdup(readme);
 }
@@ -143,6 +156,9 @@ void cgit_print_repo_readme(char *path)
 	char *filename, *ref;
 	cgit_parse_readme(ctx.repo->readme, path, &filename, &ref, ctx.repo);
 
+	if (!filename)
+		return;
+
 	/* Print the calculated readme, either from the git repo or from the
 	 * filesystem, while applying the about-filter.
 	 */
s/commit/Makefile?h=daemon&id=482b094a794c56a2052be81fdb50d3da1e87d15d&follow=1'>Simplify Makefile with pattern ruleJune McEnroe 2017-09-27Remove leading blank linesJune McEnroe 2017-09-27Add merge.c to READMEJune McEnroe 2017-09-03Assert client coords are valid after movementJune McEnroe 2017-09-03Relicense AGPLJune McEnroe 2017-09-01Revert "Add client readOnly mode"June McEnroe 2017-09-01Remove clientRemove call from clientCastJune McEnroe 2017-09-01Add client readOnly modeJune McEnroe 2017-08-31Clean up merge toolJune McEnroe 2017-08-31Choose B for tiles with equal modify timesJune McEnroe 2017-08-31Add quick data file merge toolJune McEnroe 2017-08-30Use only foreground color for selecting spawnJune McEnroe 2017-08-29Add four additional spawnsJune McEnroe 2017-08-28Add respawningJune McEnroe 2017-08-26Move license above includesJune McEnroe 2017-08-26Snapshot metadataJune McEnroe 2017-08-26Add meta.c to READMEJune McEnroe 2017-08-26Use MakefileJune McEnroe