Skip to content

Commit 41f0be6

Browse files
committed
Fix a regression in the PDF link code (Issue #536)
1 parent 7cd9318 commit 41f0be6

File tree

3 files changed

+18
-11
lines changed

3 files changed

+18
-11
lines changed

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ v1.9.21 (YYYY-MM-DD)
55
--------------------
66

77
- Updated markdown parser.
8+
- Fixed a bug in the new PDF link code (Issue #536)
89

910

1011
v1.9.20 (2024-12-09)

Makedefs.in

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#
22
# Makefile definitions for HTMLDOC, an HTML document processing program.
33
#
4-
# Copyright © 2011-2023 by Michael R Sweet.
4+
# Copyright © 2011-2025 by Michael R Sweet.
55
# Copyright © 1997-2010 by Easy Software Products.
66
#
77
# This program is free software. Distribution and use rights are outlined in
@@ -16,7 +16,6 @@ AR = @AR@
1616
AWK = @AWK@
1717
CC = @CC@
1818
CXX = @CXX@
19-
CHMOD = @CHMOD@
2019
CP = @CP@
2120
INSTALL = @INSTALL@
2221
LN = /bin/ln -sf

htmldoc/ps-pdf.cxx

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)