Repository navigation
Web app links that carry data: ?data=, ?style=, ?tiles= - #121
Conversation
|
Warning Review limit reachedYou'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. View limit details
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. Comment |
Code reviewI read the full diff and the surrounding code ( Bugs
Security
Performance
Quality
CLAUDE.md
|
Code reviewI 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
Security
Performance
Quality
CLAUDE.md / AGENTS.md
|
Code reviewThe change is small and fits the repo's conventions. I read the diff and the surrounding Bugs
Security
Performance
Quality
CLAUDE.md
|
Code reviewThe change is small and fits the existing code. I found no crashes or security problems, but there are a few edge cases where Bugs
Security
Performance
Quality
CLAUDE.md / AGENTS.md
|
📖 Docs preview
|
| // 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); |
There was a problem hiding this comment.
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); | ||
| } | ||
| } |
There was a problem hiding this comment.
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.
Code reviewThe PR is small and clean overall. I read the diff and Bugs
Security
Performance
Quality
CLAUDE.md (AGENTS.md)
|
| } | ||
| self.map.invalidate(); | ||
| } | ||
| Err(e) => self.session.notify(if e.starts_with(&url) { e } else { format!("{url}: {e}") }, true), |
There was a problem hiding this comment.
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()) |
There was a problem hiding this comment.
Two small points about params:
take(max)runs beforedecode_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 withlog::warn!as?lang=does.- It duplicates the split/decode logic of
paramjust below.paramcould be written asparams(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); |
There was a problem hiding this comment.
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)
Code reviewI 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
Security
Performance
Quality
CLAUDE.md / AGENTS.md
|
Part of #77 (Data formats & sources › Data deep links). Stacked on #116, whose background download it uses; the base moves to
mainonce #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.addDownloadtakes"zoom": trueto zoom to what it adds, whatever the map already held.ui.addUrlpasses it through.Tests
tests::downloads_land_in_their_own_projectnow also checks that a download with"zoom": truezooms the World Atlas map to Sydney.cargo xtask cipasses, and the wasm build succeeds.?blank&data=…in a browser once it's up, and add the result here.