diff options
author | Shaun McCance <shaunm@gnome.org> | 2021-12-02 15:14:04 -0500 |
---|---|---|
committer | Shaun McCance <shaunm@gnome.org> | 2021-12-02 15:14:04 -0500 |
commit | b93fb44a90f8c7cd9f6137ea191591ddff1deb56 (patch) | |
tree | 9c417ed9281af44d062e5d8bf98349b1dfcfbb26 /libyelp/yelp-uri-builder.c | |
parent | a438d408ae16ec4c686035cef91b3cb4e54f0f5b (diff) | |
download | yelp-b93fb44a90f8c7cd9f6137ea191591ddff1deb56.tar.gz |
Be even more careful about stripping slashes
We broke absolute file paths in 41.beta, then we fixed them, but
it turns out ghelp URIs were still broken. The fix isn't great,
but it should work fine.
Fixes #187
Diffstat (limited to 'libyelp/yelp-uri-builder.c')
-rw-r--r-- | libyelp/yelp-uri-builder.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/libyelp/yelp-uri-builder.c b/libyelp/yelp-uri-builder.c index 72084596..680bf90b 100644 --- a/libyelp/yelp-uri-builder.c +++ b/libyelp/yelp-uri-builder.c @@ -109,7 +109,13 @@ build_yelp_uri (const gchar *uri_str) memmove (resource, resource + 1, strlen (resource)); } else if (g_str_has_prefix (uri, "ghelp:")) { - if (resource[0] == '/' && resource[1] == '/') + /* This is an ugly heuristic that probably always works. The URI + mangling ends up not distinguishing between absolute file paths + and ordinary old ghelp URIs. But absolute file paths should + have more than one slash, right? This will fail: + cp foo.xml / && yelp /foo.xml + */ + if (resource[0] == '/' && !strchr (resource + 1, '/')) memmove (resource, resource + 1, strlen (resource)); } } |