Skip to content

Commit fc22894

Browse files
kjkclaude
andcommitted
fix EngineDjVu::HandleLink failing on named TOC links like '#vii'
ParseDjVuLink uses atoi() which returns 0 for non-numeric names. Now tries ResolveNamedDestTemp() to look up named pages before failing. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 5016325 commit fc22894

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/EngineDjVu.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1125,6 +1125,13 @@ bool EngineDjVu::HandleLink(IPageDestination* dest, ILinkHandler* linkHandler) {
11251125
}
11261126

11271127
int pageNo = ParseDjVuLink(link);
1128+
if ((pageNo < 1) || (pageNo > pageCount)) {
1129+
// try resolving as a named destination (e.g. "#vii" for named pages)
1130+
TempStr resolved = ResolveNamedDestTemp(link);
1131+
if (resolved) {
1132+
pageNo = ParseDjVuLink(resolved);
1133+
}
1134+
}
11281135
if ((pageNo < 1) || (pageNo > pageCount)) {
11291136
logf("EngineDjVu::HandleLink: invalid page in a link '%s', pageNo: %d, number of pages: %d\n", link, pageNo,
11301137
pageCount);

0 commit comments

Comments
 (0)