upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/src/http
diff options
context:
space:
mode:
authorDanConwayDev <DanConwayDev@protonmail.com>2026-04-10 16:42:35 +0000
committerDanConwayDev <DanConwayDev@protonmail.com>2026-04-10 16:42:35 +0000
commitdfd20a39a7ddaea07103cac45d4d79bc7e6ce0d7 (patch)
treef4d3c38c09c7b27a25f6b6933c9de0e42149c82f /src/http
parent2d74b9ca69b3a1e0b9a2359c12cc2d1979fc6130 (diff)
fix: accept any d-tag identifier; percent-encode in URLs
NIP-01 places no restriction on d tag characters and NIP-34 only recommends kebab-case without mandating it. Rejecting identifiers with whitespace or other URL-unsafe characters was therefore overly strict. The correct approach (per NIP-34 PR #2312 and GRASP-01) is to store identifiers verbatim on disk and percent-encode them when constructing URLs. The previous commit already handled the incoming direction (percent-decoding URL paths before filesystem lookup); this commit handles the outgoing direction and removes the validation restriction. Changes: - validate_identifier: drop whitespace rejection; only reject chars that are unsafe as filesystem directory names (/, \, null, . / ..) - git/mod.rs: add percent_encode() alongside percent_decode() - landing.rs: percent-encode identifier in nostr:// clone URL and gitworkshop link (also fixes a pre-existing bug where the clone URL displayed literal '{npub}' / '{identifier}' instead of the values)
Diffstat (limited to 'src/http')
-rw-r--r--src/http/landing.rs6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/http/landing.rs b/src/http/landing.rs
index 5fc1e6e..042be5e 100644
--- a/src/http/landing.rs
+++ b/src/http/landing.rs
@@ -2,6 +2,7 @@
2/// 2///
3/// Generates HTML landing page for the Nostr relay. 3/// Generates HTML landing page for the Nostr relay.
4use crate::config::Config; 4use crate::config::Config;
5use crate::git::percent_encode;
5use crate::http::nip11::RelayInformationDocument; 6use crate::http::nip11::RelayInformationDocument;
6use std::collections::HashMap; 7use std::collections::HashMap;
7 8
@@ -847,7 +848,7 @@ pub fn get_repo_html(config: &Config, npub: &str, identifier: &str) -> String {
847 <div class="card"> 848 <div class="card">
848 <div class="clone-box"> 849 <div class="clone-box">
849 <div class="clone-line"><span class="cmd">curl -Ls https://ngit.dev/install.sh | bash</span></div> 850 <div class="clone-line"><span class="cmd">curl -Ls https://ngit.dev/install.sh | bash</span></div>
850 <div class="clone-line"><span class="cmd">git clone</span> <span class="url" id="nostr-clone-url">nostr://{{npub}}/<span id="relayref"></span>/{{identifier}}</span></div> 851 <div class="clone-line"><span class="cmd">git clone</span> <span class="url" id="nostr-clone-url">nostr://{npub}/<span id="relayref"></span>/{encoded_identifier}</span></div>
851 </div> 852 </div>
852 </div> 853 </div>
853 </div> 854 </div>
@@ -867,7 +868,7 @@ pub fn get_repo_html(config: &Config, npub: &str, identifier: &str) -> String {
867 868
868 // Construct gitworkshop link: gitworkshop.dev/npub/relayref/identifier 869 // Construct gitworkshop link: gitworkshop.dev/npub/relayref/identifier
869 const gitworkshopLink = document.getElementById('gitworkshop-link'); 870 const gitworkshopLink = document.getElementById('gitworkshop-link');
870 gitworkshopLink.setAttribute('href', 'https://gitworkshop.dev/{npub}/' + relayref + '/{identifier}'); 871 gitworkshopLink.setAttribute('href', 'https://gitworkshop.dev/{npub}/' + relayref + '/{encoded_identifier}');
871 872
872 // Set footer domain 873 // Set footer domain
873 var footerDomain = document.getElementById('footer-domain'); 874 var footerDomain = document.getElementById('footer-domain');
@@ -882,6 +883,7 @@ pub fn get_repo_html(config: &Config, npub: &str, identifier: &str) -> String {
882 relay_name = config.relay_name(), 883 relay_name = config.relay_name(),
883 npub = npub, 884 npub = npub,
884 identifier = identifier, 885 identifier = identifier,
886 encoded_identifier = percent_encode(identifier),
885 version = get_version(), 887 version = get_version(),
886 theme_toggle = get_theme_toggle_html(), 888 theme_toggle = get_theme_toggle_html(),
887 theme_script = get_theme_script(), 889 theme_script = get_theme_script(),