Custom protocols for safe url

I’m new to Hugo and I wish to contribute with an option to specify custom protocols for a safe URL. The idea is to specify an option in config say “safeURLProtocols” as a comma separated list of allowed protocols and then use them at isSafeURL in tpl/internal/go_templates/htmltemplate/url.go. I’m pretty new at go and I couldn’t see any way to reach the configuration from there. Any hint on how can I do it? Or feedback on what I’m trying to do?
Thanks!

1 Like

Which protocols are you trying to add? I ask, as I use lots of protocol schemes others do not (gopher, irc, xmpp, etc.), and know there are various ways to get Hugo templates to render my URLs. Which challenge are you running into? If we know, we’ll know which potential system is affecting URLs (the markdown renderer, the go template parser, etc.). :slight_smile:

Well, right now I wish to use the tel protocol for a link. But I would like to use any protocol I want without touching any single line of code of an existing template. I think that the use of http, https and mailto is a sane default by the way. I propose to change this default in config if I want to allow any kind of links by manually specifying any allowed protocol.

I use URLs in a lot of contexts (and templates). Are you referring to the content of a markdown file?

Yes. I’m referring to the context of a markdown file. Url’s specified inside config.

You could adjust the markdown render hooks.