@@ -4129,7 +4129,8 @@ parse_doc(tree_t *t, /* I - Tree to parse */
41294129 {
41304130 // Add file links, stripping any trailing HTTP GET parameters...
41314131 uchar newname[256 ], // New filename
4132- *sep; // "?" separator in links
4132+ *sep, // "?" separator in links
4133+ *base; // Base path/URL
41334134 int linkpage; // Link page
41344135
41354136 // Figure out what page the file will actually start on...
@@ -4146,18 +4147,24 @@ parse_doc(tree_t *t, /* I - Tree to parse */
41464147 }
41474148
41484149 // Base filename link...
4149- strlcpy ((char *)newname, (char *)htmlGetVariable (t, (uchar *)" _HD_FILENAME" ), sizeof (newname));
4150- if ((sep = (uchar *)strchr ((char *)newname, ' ?' )) != NULL )
4151- *sep = ' \0 ' ;
4150+ if ((base = htmlGetVariable (t, (uchar *)" _HD_FILENAME" )) != NULL )
4151+ {
4152+ strlcpy ((char *)newname, (char *)base, sizeof (newname));
4153+ if ((sep = (uchar *)strchr ((char *)newname, ' ?' )) != NULL )
4154+ *sep = ' \0 ' ;
41524155
4153- add_link (NULL , newname, linkpage, (int )*top);
4156+ add_link (NULL , newname, linkpage, (int )*top);
4157+ }
41544158
41554159 // Relative filename link...
4156- strlcpy ((char *)newname, (char *)htmlGetVariable (t, (uchar *)" _HD_URL" ), sizeof (newname));
4157- if ((sep = (uchar *)strchr ((char *)newname, ' ?' )) != NULL )
4158- *sep = ' \0 ' ;
4160+ if ((base = htmlGetVariable (t, (uchar *)" _HD_URL" )) != NULL )
4161+ {
4162+ strlcpy ((char *)newname, (char *)base, sizeof (newname));
4163+ if ((sep = (uchar *)strchr ((char *)newname, ' ?' )) != NULL )
4164+ *sep = ' \0 ' ;
41594165
4160- add_link (NULL , newname, linkpage, (int )*top);
4166+ add_link (NULL , newname, linkpage, (int )*top);
4167+ }
41614168 }
41624169
41634170 if (chapter == 0 && !title_page)
0 commit comments