Skip to content

fix: URL-encode node names in web UI links and redirects (#396, #414)#447

Open
makaiver wants to merge 2 commits into
ytti:masterfrom
makaiver:fix/issue-396-encode-node-names
Open

fix: URL-encode node names in web UI links and redirects (#396, #414)#447
makaiver wants to merge 2 commits into
ytti:masterfrom
makaiver:fix/issue-396-encode-node-names

Conversation

@makaiver

@makaiver makaiver commented Jul 3, 2026

Copy link
Copy Markdown

Pre-Request Checklist

  • Passes rubocop code analysis (try rubocop --auto-correct)
  • Tests added or adapted (try rake test)
  • User-visible changes appended to CHANGELOG.md

Description

Two related bugs with the same root cause: node names are interpolated into web
UI URLs without URL-encoding, so nodes whose names contain special characters
produce broken links.

#396 — spaces break version comparison

For a node like router1 [192.168.1.1], the first diff works but selecting a
second version to compare shows "No differences available." The
POST /node/version/diffs handler redirected with an unencoded Location:
header; the raw space corrupted the query, the follow-up GET got a truncated
node, and no diff was found. (The first comparison only worked because a
browser auto-encodes spaces in an <a href>.)

#414+ breaks the versions page

For a node like router1+(test123+), opening /node/version?node_full=… fails,
because a + in a query string is decoded to a space server-side. The
?node_full= links were built by raw interpolation of full_name.

Fix

Add a small url_param helper (Rack::Utils.escape) and apply it everywhere a
node name is interpolated into a URL:

Output is byte-identical for names without special characters, so existing
behaviour and tests are unchanged.

The /node/fetch/… and /node/next/… path links are intentionally left as-is:
they rely on the literal / group separator (encoding it would break routing),
and + is not space-decoded in a path segment.

Tests

Closes #396
Closes #414

The version-comparison feature built query strings by raw string
interpolation of the node name. When a node name contains spaces or
other special characters (e.g. "router1 [192.168.1.1]"), selecting a
second version POSTs to /node/version/diffs, whose handler redirected
with an unencoded Location header. The raw space corrupted the query,
the follow-up GET received a truncated node, and the UI showed
"No differences available". The first comparison worked only because a
browser auto-encodes spaces in an <a href>.

Add a url_param helper (Rack::Utils.escape) and use it at the three
sites that interpolate node/group/oid into a diff URL: the POST redirect
in webapp.rb and the query strings built in versions.haml and diffs.haml.
Output is byte-identical for names without special characters, so
existing behaviour and tests are unchanged.

Fixes ytti#396

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@makaiver makaiver marked this pull request as ready for review July 3, 2026 10:25
…#414)

The ?node_full= links in nodes.haml, node.haml, diffs.haml and version.haml
interpolated the node name (full_name) unencoded. A "+" in the name is decoded
to a space in a query string, so opening the versions page for a node like
"router1+(test123+)" failed. Encode those links with the same url_param helper.

The /node/fetch and /node/next PATH links are intentionally left unencoded: they
rely on the literal "/" group separator, and "+" is not space-decoded in a path.

Fixes ytti#414

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@makaiver makaiver changed the title fix: URL-encode node names in version diff links and redirect (#396) fix: URL-encode node names in web UI links and redirects (#396, #414) Jul 3, 2026
@makaiver makaiver marked this pull request as draft July 3, 2026 10:43
@makaiver makaiver marked this pull request as ready for review July 3, 2026 10:47
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.

Plus (+) in hostnames causes non working URLs The version comparison doesn't work correctly.

1 participant