ITADN

Fix XPath syntax errors and hash validation false positives

#873Pull RequestZoeLeBlanc 创建于 2026-03-27
Z
ZoeLeBlanccommented
## Fix XPath syntax errors in internal hash validation ### Problem htmlproofer was throwing `Invalid number of arguments` XPath syntax errors when checking internal link hashes on large HTML documents. Additionally, valid hashes were being incorrectly reported as missing for URLs without file extensions (e.g., `/en/lessons/path#hash` which resolve to index files). I tested this on the @programminghistorian jekyll repository locally and happy to provide additional details or code snippets! ### Root Causes 1. **XPath Syntax**: The `concat()` function was being called with only one argument for simple fragment IDs, which is invalid in XPath 2. **Extension Checking**: URLs without file extensions were being rejected before file-based hash validation could occur ### Solution 1. **Smart concat() usage**: Only use `concat()` when the fragment ID contains single quotes that need escaping. For simple IDs, use plain quoted strings. 2. **Deferred checking**: URLs without known extensions now defer to file-based checking instead of being rejected immediately I included comments for the fixes but happy to remove those or update them as needed. Can't thank you enough for all your hard work on this project, it's been crucial infrastructure for us, so hoping these small tweaks can be merged in without much trouble.
合并状态:未合并 关闭于 2026-03-29 4 条评论