gomarkdown / markdown

markdown parser and HTML renderer for Go
Other
1.37k stars 172 forks source link

Allow adding extra entries in the list of safe URIs #241

Closed onionltd closed 2 years ago

onionltd commented 2 years ago

List of URI schemes is ever growing and instead of hard coding the values, the library should let its users extend the list with whatever values they want. It's only allowed to add to the list (of default values), because I consider the situation where someone doesn't want the default schemes auto-linked as unlikely.

Use of append at these particular places may have some impact on performance. I ran the benchmarks but as someone who's not experienced writing benchmarks, I can't be sure. I would appreciate someone's help.

kjk commented 2 years ago

It should be a callback function (IsSafeURL(uri []byte) bool or some such. More flexible.

onionltd commented 2 years ago

It should be a callback function (IsSafeURL(uri []byte) bool or some such. More flexible.

What is the intended behavior? Does the new IsSafeURL callback overrides internal isSafeLink? Please elaborate.

kjk commented 2 years ago

Sorry for late response.

Yes, IsSafeURL() would override isSafeLink. isSafeLink could be made public to make things easier for those using IsSafeURL()

kjk commented 2 years ago

Not the right approach.

onionltd commented 2 years ago

Follow up PR.