Commit edce0ca
committed
feat: add --external-links flag for cross-origin links
Adds opt-in support for external (cross-origin) links in HTML
directory listings, resolving issue #135.
When --external-links is passed, the HTML parser detects <a href>
tags pointing to different origins, extracts the filename, and
exposes those files and directories alongside the local listing.
Key design & security decisions:
- First-wins deduplication: if two external links produce the same
filename, the first one encountered is kept.
- HTTP credentials (-u/-p) are scoped to the mounted (root) server
only. External servers returning HTTP 401/403 trigger a
user-visible warning.
- External links ending with '/' are treated as directories;
navigating into them triggers a recursive LinkTable_new() on
the remote URL.
- LinkTable_fill() detects pre-populated f_url and skips URL
construction for external links.
- Same-origin URLs shorter than ROOT_LINK_OFFSET are protected
from buffer over-reads.
- Made URL scheme and host comparisons case-insensitive per
RFC 3986 in is_external_url and is_cross_origin.
- Stripped fragment identifiers (#) along with query parameters
when extracting filenames in external_url_to_filename.
- Sanitized unescaped path in LinkTable_new to prevent path
traversal via ".." for external links.
- Ignored "." and ".." filenames when parsing external links.
- Refactored LinkHashSet_free to avoid const-cast qualifier drop.
- Sanitized URL-decoded slash characters in external filenames to
prevent path traversal or invalid FUSE entry names.1 parent ab5f6f0 commit edce0ca
7 files changed
Lines changed: 1034 additions & 54 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
52 | 59 | | |
53 | 60 | | |
54 | 61 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
115 | 115 | | |
116 | 116 | | |
117 | 117 | | |
| 118 | + | |
| 119 | + | |
118 | 120 | | |
119 | 121 | | |
120 | 122 | | |
| |||
0 commit comments