Compare commits
3 Commits
4df3742b37
...
6d179c3a25
Author | SHA1 | Date |
---|---|---|
Archilocos | 6d179c3a25 | |
Fufu Fang | 595c6d275e | |
chrysn | bd33966337 |
43
src/link.c
43
src/link.c
|
@ -408,20 +408,6 @@ 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)) {
|
||||
|
@ -1115,12 +1101,33 @@ 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, but our code
|
||||
expects them to be relative, so change the contents of link_url as
|
||||
needed to accommodate that.
|
||||
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.
|
||||
*/
|
||||
|
||||
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! */
|
||||
/* 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).
|
||||
*/
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue