@@ -1113,12 +1113,33 @@ long path_download(const char *path, char *output_buf, size_t req_size,
11131113static void make_link_relative (const char * page_url , char * link_url )
11141114{
11151115 /*
1116- Some servers make the links to subdirectories absolute, but our code
1117- expects them to be relative, so change the contents of link_url as
1118- needed to accommodate that.
1116+ Some servers make the links to subdirectories absolute (in URI terms:
1117+ path-absolute), but our code expects them to be relative (in URI terms:
1118+ path-noscheme), so change the contents of link_url as needed to
1119+ accommodate that.
1120+
1121+ Also, some servers serve their links as `./name`. This is helpful to
1122+ them because it is the only way to express relative references when the
1123+ first new path segment of the target contains an unescaped colon (`:`),
1124+ eg in `./6:1-balun.png`. While stripping the ./ strictly speaking
1125+ reintroduces that ambiguity, it is of little practical concern in this
1126+ implementation, as full URI link targets are filtered by their number of
1127+ slashes anyway. In URI terms, this converts path-noscheme with a leading
1128+ `.` segment into path-noscheme or path-rootless without that segment.
11191129 */
1130+
1131+ if (link_url [0 ] == '.' && link_url [1 ] == '/' ) {
1132+ memmove (link_url , link_url + 2 , strlen (link_url ) - 1 );
1133+ return ;
1134+ }
1135+
11201136 if (link_url [0 ] != '/' ) {
1121- /* Already relative, nothing to do here! */
1137+ /* Already relative, nothing to do here!
1138+
1139+ (Full URIs, eg. `http://example.com/path`, pass through here
1140+ unmodified, but those are classified in different LinkTypes later
1141+ anyway).
1142+ */
11221143 return ;
11231144 }
11241145
0 commit comments