Skip to content

Commit

Permalink
Add support for deeper ../ links (Issue #534)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelrsweet committed Dec 5, 2024
1 parent b4ded8a commit 0937548
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions htmldoc/htmllib.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -3634,14 +3634,19 @@ htmlFixLinks(tree_t *doc, // I - Top node
char parent[1024], *pptr; // Parent directory

strlcpy(parent, (char *)base, sizeof(parent));
if ((pptr = strrchr(parent, '/')) != NULL)
pptr[1] = '\0';
else
parent[0] = '\0';
while (!strncmp((char *)href, "../", 3))
{
href += 3;

if ((pptr = strrchr(parent, '/')) != NULL)
pptr[1] = '\0';
else
parent[0] = '\0';
}

DEBUG_printf(("htmlFixLinks: Subdirectory, parent=\"%s\"\n", parent));

snprintf(full_href, sizeof(full_href), "%s%s", parent, href + 3);
snprintf(full_href, sizeof(full_href), "%s%s", parent, href);
}
else
{
Expand Down

0 comments on commit 0937548

Please sign in to comment.