Skip to content

Web app links that carry data: ?data=, ?style=, ?tiles= - #121

Merged
giswqs merged 1 commit into
mainfrom
deep-links
Oct 13, 2026
Merged

giswqs merged 1 commit into
mainfrom
deep-links

Conversation

@giswqs

@giswqs giswqs commented Oct 13, 2026

Copy link
Copy Markdown
Member

Part of #77 (Data formats & sources › Data deep links). Stacked on #116, whose background download it uses; the base moves to main once #116 merges.

What changes

  • ?data=<address> adds a file by its web address when the web app opens. It's repeatable, up to 16 times; files download in the background as From URL… does, and the map zooms to the first.
  • ?style=<address> adds a MapLibre style, and ?tiles=<template> adds a tile layer (up to 8 of each).
  • layer.addDownload takes "zoom": true to zoom to what it adds, whatever the map already held. ui.addUrl passes it through.
  • The docs (installation › web app links) describe the parameters, with an example that opens USGS's earthquakes of the past week.
  • Ported from an earlier, unmerged branch onto Add data by its web address: GeoJSON, CSV, GeoParquet, COG and more #116's download path.

Tests

  • tests::downloads_land_in_their_own_project now also checks that a download with "zoom": true zooms the World Atlas map to Sydney.
  • cargo xtask ci passes, and the wasm build succeeds.
  • I'll open the preview deploy with ?blank&data=… in a browser once it's up, and add the result here.

@coderabbitai

coderabbitai Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 55 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 2 included reviews currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: e7d9a824-ddac-43f0-a3ef-f67b83a15275
📥 Commits

Reviewing files that changed from the base of the PR and between 0a266e9 and 5439f73.

📒 Files selected for processing (5)
  • apps/rustgis-web/src/web.rs
  • crates/engine/src/cmd/layer.rs
  • crates/engine/src/tests.rs
  • crates/ui-egui/src/lib.rs
  • docs/installation.md
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Comment thread apps/rustgis-web/src/web.rs Resolved
Comment thread crates/engine/src/cmd/layer.rs Resolved
@github-actions

Copy link
Copy Markdown
Contributor

Code review

I read the full diff and the surrounding code (add_named_bytes, the map.addTiles and ui.addUrl handlers, and the result shapes of the add commands). I did not build or run anything. The change is small and fits the repo's conventions: it has no unwrap and no panics, the engine side builds for wasm, and the u32::try_from conversion is safe. I posted 2 inline comments.

Bugs

  • Zoom with several layers, or empty or degenerate extents (low–medium confidence). layer.addDownload with "zoom": true zooms only to the first added layer id (crates/engine/src/cmd/layer.rs). For zip, KML or GPX files that add several layers, the map frames only the first. An empty or single-point layer may also give a degenerate extent, so check that zoom_to copes. The new test covers only a single point and passes with a loose 0.5° tolerance.
  • .pmtiles links ignore zoom (low confidence). ?data=….pmtiles is routed to layer.addUrl, which doesn't read zoom, so the "zooms to the first" behaviour silently doesn't apply.
  • "Zoom to the first" depends on which download finishes first (medium confidence). zoom: i == 0 marks the first listed URL. Downloads finish asynchronously, so if that URL fails, nothing zooms. The docs imply that it always does.

Security

  • Links trigger third-party fetches with no confirmation (medium confidence). ?data=, ?style= and ?tiles= make the app request arbitrary URLs on load and add attacker-chosen styles or tiles to the user's map. Assistant and plugin network use asks for approval first, but this path doesn't. CORS limits the impact, but a crafted link can still cause requests to attacker-chosen hosts. It also exposes the visitor's IP address and can be used for tracking. Consider a toast naming the loaded hosts, or a confirmation for cross-origin links.
  • The 16/8 caps on repeated parameters, the blank-value filter and the use of decode_uri_component are sound.

Performance

  • Nothing notable. Up to 16 background downloads start at once, which is bounded.

Quality

  • The [("style", Some("style")), ("tiles", None)] loop in apps/rustgis-web/src/web.rs is indirect. Two plain loops or a small helper would be clearer.
  • params() duplicates the parsing in param(). param could be built on top of it.
  • The new code in web.rs is wasm-only, so nothing tests it, including +-as-space handling and the caps. A small unit test of the parsing, factored into a non-wasm helper, would help.

CLAUDE.md

  • No unwrap, panic or unsafe is added. zoom is an optional bool, so junk values are ignored and hostile_params_never_panic should stay green.
  • The new log messages are developer logs, so they need no tl!. The Downloading {url}… notification already goes through i18n::fmt.
  • The command's params doc string is updated and the docs describe the new parameters.

Comment thread apps/rustgis-web/src/web.rs Resolved
Comment thread crates/engine/src/cmd/layer.rs Resolved
@github-actions

Copy link
Copy Markdown
Contributor

Code review

I read the diff and the surrounding code. I did not build the code or run any tests. The change is small and consistent with the architecture, and I found no crash or security bugs. I posted two inline comments.

Bugs

  • Zoom only applies to the first ?data= (medium confidence). If that first download fails (CORS, 404) the map never zooms, even if later files load. The .pmtiles branch of ui.addUrl and MBTiles results also ignore "zoom" (web.rs).
  • MBTiles results silently skip "zoom": true (low confidence). The tile-layer result has no layer id. The r.get("layers").and_then(|l| l.get(0)) fallback is redundant, because add_layers always sets layer (layer.rs).

Security

  • Third-party fetches on load (low, by design). ?style=, ?tiles= and ?data= make the app contact arbitrary servers as soon as the link opens. This is inherent to share links, and it is bounded (16 data links, 8 style and 8 tile links). The docs could say that opening such a link contacts those servers. The parameters go through ui.addUrl and map.addTiles, which already validate URLs, so I found no injection path.

Performance

  • Nothing to raise.

Quality

  • Failures are silent (medium). A bad link only produces log::warn!. ui.addUrl returning Ok means only that the download started, so the user may see nothing when it fails.
  • Query parsing is fine (low). params() decodes + as a space before percent-decoding. That is correct for query strings, but it would mangle a literal + in a URL that wasn't encoded as %2B. Share links should percent-encode.

CLAUDE.md / AGENTS.md

  • Translation: the new strings are all log::warn! messages, so no tl! is needed.
  • No unwrap, expect or panic was added in non-test code. The new test uses unwrap, which is allowed.
  • Wasm and layering: the change is compatible with both.
  • Test coverage: the regression test for zoom: true is present. Nothing tests the params() parser, since it is wasm-only.

Comment thread crates/engine/src/cmd/layer.rs Resolved
Comment thread apps/rustgis-web/src/web.rs Resolved
@github-actions

Copy link
Copy Markdown
Contributor

Code review

The change is small and fits the repo's conventions. I read the diff and the surrounding ui.addUrl, add_named_bytes and map.addTiles code. I didn't build or run tests. The unwrap/panic rules and the wasm-only js_sys use in apps/ are respected, and no new interface strings are added.

Bugs

  • + is turned into a space before decoding (apps/rustgis-web/src/web.rs:126, confidence: medium-low). A literal + in a web address, such as ?data=https://x.org/a+b.geojson, is corrupted. This matches the existing param(), but it matters more now that the values are URLs. An unencoded & in a data URL also splits it. The docs should say the value must be percent-encoded.
  • The zoom lookup in add_download may miss some results (crates/engine/src/cmd/layer.rs:1014, confidence: low-medium).
    • It reads r["layer"] or r["layers"][0] as a numeric id. Only the raster path is confirmed to return {"layer": id}. Vector, zip/KML/GPX and tile results may return a different shape, and then ?data= silently doesn't zoom.
    • The new test covers only a single GeoJSON point, whose extent has zero size. It checks the camera center but not that the zoom level is sensible.
    • A test with a multi-layer file or a raster would settle both points.

Security

  • Nothing new. ?data= and ?tiles= go through the existing ui.addUrl and map.addTiles commands, which already reject file:// and private addresses (existing tests cover this). The new code caps the count at 16 and 8.
  • Anyone can craft a link that makes the app fetch an arbitrary URL on open. That is inherent to the feature, and the existing network checks apply.

Performance

  • Up to 16 downloads start in parallel at page load. This is bounded and acceptable.

Quality

  • Failures from the query parameters only go to log::warn!. A user who follows a bad link gets no visible notice, so a notify might be friendlier.

CLAUDE.md

  • No violations found.

Base automatically changed from data-from-url to main October 13, 2026 07:44
Comment thread crates/engine/src/cmd/layer.rs Resolved
Comment thread apps/rustgis-web/src/web.rs Resolved
@github-actions

Copy link
Copy Markdown
Contributor

Code review

The change is small and fits the existing code. I found no crashes or security problems, but there are a few edge cases where zoom does nothing. I only read the code and did not build or run it.

Bugs

  • zoom does nothing for .pmtiles data links (medium confidence). ?data= gives zoom: true only to the first address. ui.addUrl sends .pmtiles addresses to layer.addUrl, which neither downloads nor zooms. In ?data=a.pmtiles&data=b.geojson, neither file is zoomed to. (apps/rustgis-web/src/web.rs:83)
  • layer.addDownload zoom depends on the result shape (medium confidence). It looks for a layer or layers[0] id in what add_named_bytes returns. The MBTiles branch goes through tiles::add, which returns {name, kind, index} with no layer id. A downloaded MBTiles file with "zoom": true therefore silently does not zoom. Diffing the layer ids before and after the add would be sturdier. (crates/engine/src/cmd/layer.rs:1015)

Security

  • Nothing found. ?style= and ?tiles= go through map.addTiles, which already rejects file:// and local paths. The caps of 16 ?data= and 8 each of ?style= and ?tiles= bound how much a link can add. Links that add data from addresses in the URL are by design, and the docs mention the CORS requirement.

Performance

  • params() decodes every matching query value before .take(16) or .take(8) caps the count. This is minor, and it would only matter for a very long query string.

Quality

  • Tests: The new test checks only a GeoJSON point download with zoom: true. It does not cover the web-side parsing in params(), ?style=, ?tiles=, or the cases above that don't zoom.
  • Param docs: The layer.addDownload param string now lists "zoom"?: bool, which matches the other commands.

CLAUDE.md / AGENTS.md

  • No unwrap, unsafe or panic. Errors are logged with log::warn!.
  • The new code sits in web.rs, the engine command and the UI, and builds for wasm. The new log messages are developer-facing, so they don't need tl!().
  • The PR description says cargo xtask ci passes and the wasm build succeeds. I could not check either.

@github-actions

github-actions Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

📖 Docs preview

Item Value
Preview https://pr-121.rustgis-preview.pages.dev
Web app https://pr-121.rustgis-preview.pages.dev/app/
This commit https://c2d8d109.rustgis-preview.pages.dev
Commit 5439f73

Comment thread crates/ui-egui/src/lib.rs
// A failure is said by `run`.
if self.run("layer.addDownload", p).is_ok() {
self.map.invalidate();
let zoom = p.get("zoom").and_then(Value::as_bool) == Some(true);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

link_zoomed is never reset. Once a ?data= file has zoomed the map, it stays true for the whole session. That includes later ui.addUrl calls that pass "zoom": true explicitly, because they are also suppressed here. It also includes any later project opened in the same visit. The flag's doc comment says it covers the link's data, but the code treats it as a global. Consider clearing it when a project opens, or scoping it to the link's download ids.

Also, run only logs errors. The old comment said "A failure is said by run", so the new notify here is probably correct. Please confirm that other paths (the Err(e) branch below) don't also notify, to avoid duplicate notices. Confidence: medium.

if let Err(e) = app.run("map.addTiles", p) {
app.session.notify(format!("?{key}={url}: {e}"), true);
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor: map.addTiles is called for each ?style= or ?tiles= URL with no scheme check. A shared link can make the app fetch from any host the link names, which exposes the visitor's IP and Referer to a third party. The ?data= path has the same property. This is probably acceptable for a deep-link feature, but you may want the docs to say so, or restrict the scheme to http/https. Confidence: low.

@github-actions

Copy link
Copy Markdown
Contributor

Code review

The PR is small and clean overall. I read the diff and run in crates/ui-egui/src/lib.rs. I did not build the code or run the tests.

Bugs

  • link_zoomed is never reset (crates/ui-egui/src/lib.rs, ~L1524). Once a ?data= file zooms the map, the flag stays true for the whole session. It then suppresses "zoom": true for later ui.addUrl calls and for projects opened afterwards. Reset it when a project opens, or scope it to the link's downloads. Confidence: medium.
  • Possible duplicate error notices (same spot). The old comment said run reports failures, but run only logs them. The new notify in the Err arm looks correct. Check that the other Err(e) branch doesn't also notify. Confidence: low–medium.

Security

  • No scheme or host restriction on link URLs (apps/rustgis-web/src/web.rs, ~L98). A shared link can make the app fetch ?data=, ?style= and ?tiles= URLs from any host. That exposes the visitor's IP and Referer to whoever controls the host. CORS limits what the app can read, but not that the request is sent. This is probably acceptable for a deep-link feature. Consider noting it in the docs or limiting the scheme to http/https. Confidence: low.

Performance

  • Nothing to raise. The 16 and 8 caps on repeated parameters bound the work.

Quality

  • params() caps with .take(max) before decoding, so entries that fail to decode use up slots. That is harmless.
  • The [("style", Some("style")), ("tiles", None)] loop is slightly obscure. Two plain loops would read more clearly. Nit.
  • zoom_to_added is well-contained. The tests cover single-layer, multi-layer (GPX) and no-zoom cases.

CLAUDE.md (AGENTS.md)

  • No unwrap, expect or unsafe was added.
  • The new notices are built with format! (?data={url}: {e}, {url}: {e}) rather than tl! / i18n::fmt. If these are user-visible notices, they may need translation and entries in crates/ui-egui/src/i18n/*.tsv. Confidence: medium.
  • web.rs builds for wasm. It uses js_sys, and no std::time was added.
  • layer.addDownload has a new zoom parameter. I didn't check whether hostile_params_never_panic already covers it. A non-bool value is ignored, so a panic is unlikely.

Comment thread crates/ui-egui/src/lib.rs
}
self.map.invalidate();
}
Err(e) => self.session.notify(if e.starts_with(&url) { e } else { format!("{url}: {e}") }, true),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: this error-formatting expression is now duplicated verbatim at line 1560 (the download-failure arm). A small closure or helper would avoid the copy. The Err arm here also replaces the old "a failure is said by run" behaviour. RustGisApp::run only logs at info level, so the notice added here is needed. Worth confirming that no other path also notifies, to avoid duplicate toasts. (Confidence: low-medium)

q.trim_start_matches('?')
.split('&')
.filter_map(|kv| kv.strip_prefix(key)?.strip_prefix('='))
.filter(|raw| !raw.trim().is_empty())

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two small points about params:

  1. take(max) runs before decode_uri_component, so a malformed value (e.g. a stray %) is dropped silently. It also uses up one of the 16 slots. Nothing is reported to the user for it, although the PR says failures are "said in a notice". Consider logging with log::warn! as ?lang= does.
  2. It duplicates the split/decode logic of param just below. param could be written as params(q, key, 1).into_iter().next(), though the empty-value filtering would need to match.
    (Confidence: medium on 1, low on 2)

// layer. Links that share a map. What fails is said in a notice.
for url in params(&q, "data", 16) {
if let Err(e) = app.run("ui.addUrl", serde_json::json!({"url": url, "zoom": true})) {
app.session.notify(format!("?data={url}: {e}"), true);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Design and security note: any web page can now make a visitor's browser fetch arbitrary URLs (up to 16 data, 8 style and 8 tiles) and load them as layers just by linking to the app. The fetches are bounded by CORS, so the main exposure is tracking and bandwidth, plus parser attack surface from hostile files. That seems acceptable and the docs mention CORS. The existing "From URL" flow is user-initiated and this one is not, so consider a size limit or a visible notice for link-supplied data. Also, ?tiles= and ?style= URLs go straight to map.addTiles with no scheme check. It's worth confirming that it rejects file: and data: templates. (Confidence: low-medium)

@github-actions

Copy link
Copy Markdown
Contributor

Code review

I read the diff and the surrounding code. I found no definite bugs. I did not build the code or run the tests, so I haven't checked the new engine test or the browser behaviour. The inline comments are on the points below.

Bugs

  • None found. The zoom code in zoom_to_added reads numeric layer ids from the result. I checked that add_layers and add_data_text return ids in layer and layers, not names. Tile archives add no layer, so they correctly report zoomed: false.
  • Low confidence: params() in web.rs applies take(max) before percent-decoding. A malformed value (a stray %) is dropped silently and uses up one of the 16 slots. The PR says failures are "said in a notice", but this one isn't. A log::warn!, as ?lang= does, would fix it.
  • Low confidence: link_zoomed is only set when a file actually zoomed the map. So "the first file that lands with something to show" depends on download order, not link order. The docs say this, so it is a design choice, not a defect.

Security

  • Low-medium confidence: any web page can now make a visitor's browser fetch up to 16 ?data=, 8 ?style= and 8 ?tiles= URLs and load them as layers. CORS limits the exposure, which is mostly tracking, bandwidth and parser attack surface from hostile files. The existing "From URL" flow is user-initiated and this one is not, so a size limit or visible notice would help. Please also confirm that map.addTiles rejects file: and data: URL templates, since link values go to it unchecked.

Performance

  • Nothing notable. The extent union in zoom_to_added is cheap.

Quality

  • Low confidence: if e.starts_with(&url) { e } else { format!("{url}: {e}") } is now repeated twice in ui-egui/src/lib.rs. A small helper would remove the copy.
  • Low confidence: params duplicates the split and decode logic of param. param could be built on top of it.
  • Low-medium confidence: the old comment said failures from layer.addDownload are said by run. RustGisApp::run only logs at info level, so the new explicit notify is needed. Please check that no other path also notifies, to avoid duplicate toasts.

CLAUDE.md / AGENTS.md

  • No unwrap, expect, panic! or unsafe in the new code, and values are clamped (16 data, 8 style/tiles), so this follows the never-crash rule.
  • The new layer.addDownload zoom param is documented, and there is a regression test for zoom, multi-layer zoom and no-zoom.
  • Low-medium confidence: the new notices ("?data={url}: {e}" and the like) go through format!, not i18n::fmt/tl!. The guideline says interface messages should be translatable and have entries in crates/ui-egui/src/i18n/*.tsv. The web.rs notices and the per-URL failure notice in lib.rs may need that. The existing "Downloading {url}…" message in lib.rs already uses i18n::fmt.

@giswqs
giswqs merged commit f90bcce into main Oct 13, 2026
9 checks passed
@giswqs
giswqs deleted the deep-links branch October 13, 2026 08:51
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.

1 participant