Add XMPP URI support (RFC5122) #8359

Closed
opened 2025-11-02 08:03:36 -06:00 by GiteaMirror · 8 comments
Owner

Originally created by @Neustradamus on GitHub (Jan 16, 2022).

Feature Description

Dear @go-gitea team,

In first, I wish you a Happy New Year 2022!

Can you see for add XMPP URI support?
XMPP URI support must be added because it does not work.

Examples:

It is a standard:

Can you update it and solves this big bug?

There is no problem for mailto.

Thanks in advance.

Screenshots

https://i.ibb.co/cxMypjG/gitea-xmpp-uri-does-not-work-mailto-ok.png

Originally created by @Neustradamus on GitHub (Jan 16, 2022). ### Feature Description Dear @go-gitea team, In first, I wish you a Happy New Year 2022! Can you see for add XMPP URI support? XMPP URI support must be added because it does not work. Examples: - xmpp:username@domain.tld - xmpp:username@domain.tld?message - xmpp:mucroom@domain.tld?join It is a standard: - RFC5122: https://tools.ietf.org/html/rfc5122 Can you update it and solves this big bug? There is no problem for mailto. Thanks in advance. ### Screenshots https://i.ibb.co/cxMypjG/gitea-xmpp-uri-does-not-work-mailto-ok.png
GiteaMirror added the type/questionoutdated/theme/markdown labels 2025-11-02 08:03:36 -06:00
Author
Owner

@wxiaoguang commented on GitHub (Jan 16, 2022):

Can you help to describe where to support XMPP? What do you expect to see? In the markdown content or somewhere else?

@wxiaoguang commented on GitHub (Jan 16, 2022): Can you help to describe where to support XMPP? What do you expect to see? In the markdown content or somewhere else?
Author
Owner

@Neustradamus commented on GitHub (Jan 16, 2022):

@wxiaoguang: Thanks for your quickly reply!

In issue/pr/ticket/comment.

In file, like README etc.

In user/organization and repository description too:

Issue:

Project:

Wiki:

Note: mailto:test@domain.tld does not work but test@doman.tld is by default a mailto in issue/project/wiki.

@Neustradamus commented on GitHub (Jan 16, 2022): @wxiaoguang: Thanks for your quickly reply! In issue/pr/ticket/comment. In file, like README etc. In user/organization and repository description too: - https://i.ibb.co/T4gHPJc/gitea-profile-description-and-issue-description.png Issue: - https://i.ibb.co/878sCzJ/gitea-issue-example.png Project: - https://i.ibb.co/3TVfc3g/gitea-project-example.png Wiki: - https://i.ibb.co/TPp8Q4R/gitea-wiki-example.png Note: mailto:test@domain.tld does not work but test@doman.tld is by default a mailto in issue/project/wiki.
Author
Owner

@Neustradamus commented on GitHub (Jul 27, 2022):

@wxiaoguang: Hello,

Have you progressed on this issue?

Do you need help?

Thanks in advance.

@Neustradamus commented on GitHub (Jul 27, 2022): @wxiaoguang: Hello, Have you progressed on this issue? Do you need help? Thanks in advance.
Author
Owner

@wxiaoguang commented on GitHub (Jul 28, 2022):

No progress from my side, it's open to be picked up. IMO it's likely related to the markdown parser.

@wxiaoguang commented on GitHub (Jul 28, 2022): No progress from my side, it's open to be picked up. IMO it's likely related to the markdown parser.
Author
Owner

@DeathByDenim commented on GitHub (Jul 31, 2022):

I looked a bit more into this. I tried the release version of Gitea 1.17.0 to see if XMPP link are still broken, and indeed they are.
Then I tested the markdown parser which is goldmark v1.4.13 as far as I can tell. So I wrote an extremely simple test program to test goldmark:

package main

import (
        "fmt"
        "bytes"
        "github.com/yuin/goldmark"
)

func main() {
        var md bytes.Buffer
        var html bytes.Buffer
        md.WriteString("[hey](xmpp:node@example.com)")
        if err := goldmark.Convert(md.Bytes(), &html); err != nil {
                panic(err)
        }
        fmt.Println(html.String())
}

That indeed produces the correct result <p><a href="xmpp:node@example.com">hey</a></p>.

So it must be something that Gitea is doing differently. Maybe in the options it gives to goldmark or something?

@DeathByDenim commented on GitHub (Jul 31, 2022): I looked a bit more into this. I tried the release version of Gitea 1.17.0 to see if XMPP link are still broken, and indeed they are. Then I tested the markdown parser which is goldmark v1.4.13 as far as I can tell. So I wrote an extremely simple test program to test goldmark: ``` package main import ( "fmt" "bytes" "github.com/yuin/goldmark" ) func main() { var md bytes.Buffer var html bytes.Buffer md.WriteString("[hey](xmpp:node@example.com)") if err := goldmark.Convert(md.Bytes(), &html); err != nil { panic(err) } fmt.Println(html.String()) } ``` That indeed produces the correct result `<p><a href="xmpp:node@example.com">hey</a></p>`. So it must be something that Gitea is doing differently. Maybe in the options it gives to goldmark or something?
Author
Owner

@DeathByDenim commented on GitHub (Aug 1, 2022):

Well, it turns out this is not a bug at all. It's just a result of not reading the documentation and by that I mean custom/conf/app.example.ini or the cheat sheet. I traced this issue all the way to the sanitizer policies which by default strips out anything that isn't http, https, or mailto until I finally arrived at CUSTOM_URL_SCHEMES.

So it turns out that Gitea does have a setting to allow additional protocols! Add this to your custom/conf/app.ini:

[markdown]
CUSTOM_URL_SCHEMES = xmpp

You can now use XMPP links in your markdown files.

I think this issue can be closed.

@DeathByDenim commented on GitHub (Aug 1, 2022): Well, it turns out this is not a bug at all. It's just a result of not reading the documentation and by that I mean `custom/conf/app.example.ini` or the [cheat sheet](https://github.com/go-gitea/gitea/blob/main/docs/content/doc/advanced/config-cheat-sheet.en-us.md#markdown-markdown). I traced this issue all the way to the sanitizer policies which by default strips out anything that isn't http, https, or mailto until I finally arrived at `CUSTOM_URL_SCHEMES`. So it turns out that Gitea does have a setting to allow additional protocols! Add this to your `custom/conf/app.ini`: ``` [markdown] CUSTOM_URL_SCHEMES = xmpp ``` You can now use XMPP links in your markdown files. I think this issue can be closed.
Author
Owner

@Neustradamus commented on GitHub (Aug 1, 2022):

@DeathByDenim: Thanks!

How it is possible to add by default (in core) like http/https/mailto?

@Neustradamus commented on GitHub (Aug 1, 2022): @DeathByDenim: Thanks! How it is possible to add by default (in core) like http/https/mailto?
Author
Owner

@DeathByDenim commented on GitHub (Aug 1, 2022):

@Neustradamus : Oh, I'm not sure. I guess you can make it a default setting?

I think you might be able to adjust modules/setting/settings.go:330--339 to something like this:

	Markdown = struct {
		EnableHardLineBreakInComments  bool
		EnableHardLineBreakInDocuments bool
		CustomURLSchemes               []string `ini:"CUSTOM_URL_SCHEMES"`
		FileExtensions                 []string
	}{
		EnableHardLineBreakInComments:  true,
		EnableHardLineBreakInDocuments: false,
		CustomURLSchemes:               strings.Split("xmpp", ","),     // This is the new line I added
		FileExtensions:                 strings.Split(".md,.markdown,.mdown,.mkd", ","),
	}

This code above will get overwritten whenever someone sets CUSTOM_URL_SCHEMES manually. You can also search for CustomURLSchemes in the code to see where it's used and make changes there, I suppose. Ultimately, this comes from the bluemonday sanitizer that Gitea uses.

I feel you are better off just adding this setting to you app.ini every time you deploy Gitea though. It's a lot simpler than using a custom code base.

@DeathByDenim commented on GitHub (Aug 1, 2022): @Neustradamus : Oh, I'm not sure. I guess you can make it a default setting? I think you might be able to adjust [modules/setting/settings.go:330--339](https://github.com/go-gitea/gitea/blob/72b1fd7fdde76815ce3b2e6d19978fa7ade30a66/modules/setting/setting.go#L330-L339) to something like this: ``` Markdown = struct { EnableHardLineBreakInComments bool EnableHardLineBreakInDocuments bool CustomURLSchemes []string `ini:"CUSTOM_URL_SCHEMES"` FileExtensions []string }{ EnableHardLineBreakInComments: true, EnableHardLineBreakInDocuments: false, CustomURLSchemes: strings.Split("xmpp", ","), // This is the new line I added FileExtensions: strings.Split(".md,.markdown,.mdown,.mkd", ","), } ``` This code above will get overwritten whenever someone sets CUSTOM_URL_SCHEMES manually. You can also search for CustomURLSchemes in the code to see where it's used and make changes there, I suppose. Ultimately, this comes from the [bluemonday sanitizer](https://github.com/microcosm-cc/bluemonday) that Gitea uses. I feel you are better off just adding this setting to you app.ini every time you deploy Gitea though. It's a lot simpler than using a custom code base.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#8359