Compare commits

..

1 Commits

Author SHA1 Message Date
Archilocos 4df3742b37
Merge f361527459 into 29c3eb8f67 2023-10-01 17:17:23 +02:00
1 changed files with 18 additions and 25 deletions

View File

@ -408,6 +408,20 @@ static void HTML_to_LinkTable(const char *url, GumboNode *node,
* This is to prevent duplicated link, if an Apache server has the
* IconsAreLinks option.
*/
/* The following four lines of code have no effect so I've commented
them out. I'm not removing them entirely because it's possible the
original intent was to do a check of some sort here and it's an
error that this check wasn't fully implemented, in which case this
commented out code and the comment above it should serve as a
reminder to whoever originally wrote it that there's something
unfinished here that needs to be finished.
*/
/*
size_t comp_len = strnlen(link_url, MAX_FILENAME_LEN);
if (type == LINK_DIR) {
comp_len--;
}
*/
if (((type == LINK_DIR) || (type == LINK_UNINITIALISED_FILE)) &&
!linknames_equal(linktbl->links[linktbl->num - 1]->linkname,
link_url)) {
@ -1101,33 +1115,12 @@ long path_download(const char *path, char *output_buf, size_t req_size,
static void make_link_relative(const char *page_url, char *link_url)
{
/*
Some servers make the links to subdirectories absolute (in URI terms:
path-absolute), but our code expects them to be relative (in URI terms:
path-noscheme), so change the contents of link_url as needed to
accommodate that.
Also, some servers serve their links as `./name`. This is helpful to
them because it is the only way to express relative references when the
first new path segment of the target contains an unescaped colon (`:`),
eg in `./6:1-balun.png`. While stripping the ./ strictly speaking
reintroduces that ambiguity, it is of little practical concern in this
implementation, as full URI link targets are filtered by their number of
slashes anyway. In URI terms, this converts path-noscheme with a leading
`.` segment into path-noscheme or path-rootless without that segment.
Some servers make the links to subdirectories absolute, but our code
expects them to be relative, so change the contents of link_url as
needed to accommodate that.
*/
if (link_url[0] == '.' && link_url[1] == '/') {
memmove(link_url, link_url + 2, strlen(link_url) - 1);
return;
}
if (link_url[0] != '/') {
/* Already relative, nothing to do here!
(Full URIs, eg. `http://example.com/path`, pass through here
unmodified, but those are classified in different LinkTypes later
anyway).
*/
/* Already relative, nothing to do here! */
return;
}