Skip to content

fix(viewer): decode percent-encoded link targets in _extract_links - #400

Open
Sayantan181222 wants to merge 1 commit into
GoogleCloudPlatform:mainfrom
Sayantan181222:fix/percent-encoded-link-targets
Open

Sayantan181222 wants to merge 1 commit into
GoogleCloudPlatform:mainfrom
Sayantan181222:fix/percent-encoded-link-targets

Conversation

@Sayantan181222

Copy link
Copy Markdown

Problem

Bundles with spaces in filenames render with 0 edges in the visualizer.

When a markdown link points to a file with a space in its name, the link
target is percent-encoded e.g. ../metrics/gross%20margin.md. The
_extract_links function passed this raw encoded string directly to
Path for filesystem resolution. Since the real file is named
gross margin.md (not gross%20margin.md), the path lookup silently
failed and the link was dropped. As a result _build_graph saw no
matching concept id and drew no edges.

Fix

Call urllib.parse.unquote() on the raw link target before resolving
it as a filesystem path. One-line change in _extract_links.

Test

Added test_percent_encoded_links_produce_edges in test_viewer.py
which creates a bundle with a space in one filename, links to it using
%20 encoding from another concept, and asserts the edge appears in
the graph output. All 8 tests pass.

Fixes #200

Markdown tools write links to files with spaces using percent-encoding
e.g. gross%20margin.md. Path resolution was done on the raw encoded
string which never matches the real filename, so all such links were
silently dropped producing graphs with 0 edges.

Fix: call urllib.parse.unquote() on the link target before resolving
the filesystem path.

Fixes GoogleCloudPlatform#200
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

visualize: percent-encoded link targets are never decoded — bundles with spaces in filenames render with 0 edges

1 participant