RGJ
(Richard - Communiteq)
February 15, 2025, 12:16pm
1
When updating to 3.4 the Custom Header links theme component refused to update because of a Matrix link like https://matrix.to/#/#matrix-meta-chat:fedoraproject.org . Error: The property at JSON Pointer '/3/url' must be a valid URL.
Once this link was removed, the update went fine, but adding the link back was impossible.
(Workaround: create a permalink /matrix that redirects to https://matrix.to/#/#matrix-meta-chat:fedoraproject.org and then add /matrix as a custom header link)
Still, it might be good to make this a bit more flexible. Apparently the link format is fine for a permalink.
2 Likes
The double #
makes the object setting validation fail in the core (not this TC per se).
bad URI(is not URI?): "https://matrix.to/#/#matrix-meta-chat:fedoraproject.org" (URI::InvalidURIError)
It’s not strictly a valid URI, so you’d need to encode the fragment.
Here; using https://matrix.to/#/%23matrix-meta-chat:fedoraproject.org
will work.
Looking at the code:
is_valid_url
is defined here:
You can see they already have another function to deal with this situation and is being used in other places:
# At the moment this handles invalid URLs that browser address bar accepts
# where second # is not encoded
#
# Longer term we can add support of simpleidn and encode unicode domains
def self.relaxed_parse(url)
url, fragment = url.split("#", 2)
uri = URI.parse(url)
I think it’s reasonable to use relaxed_parse
for the theme object URL validation.
E.g.: if validations&.dig(:url) && !UrlHelper.relaxed_parse?(value)
4 Likes