Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] rss+xml in <head><link> is encoded into rss&#43;xml #392

Closed
JannikArndt opened this issue May 1, 2021 · 2 comments · Fixed by #393
Closed

[BUG] rss+xml in <head><link> is encoded into rss&#43;xml #392

JannikArndt opened this issue May 1, 2021 · 2 comments · Fixed by #393
Labels
bug Something isn't working

Comments

@JannikArndt
Copy link
Contributor

Describe the bug

The <link> tag gets a "safe url" encoding:

<link rel="alternate" type="application/rss&#43;xml" href="/index.xml">
  • Device/Os: MacOS 11.3
  • Hugo Version [ >=0.82.0 expected]: hugo v0.82.1+extended darwin/amd64 BuildDate=unknown
  • Theme Version [e.g. v4.0, master, or commit-id ]: master

Steps to reproduce the behavior:

Works on master:

$ git clone https://github.com/adityatelange/hugo-PaperMod.git
…
$ cd hugo-PaperMod
$ hugo
…
$ tail -n +20 public/index.html | head -n 5 

gives you

<meta name="msapplication-TileColor" content="#2e2e33">
<meta name="generator" content="Hugo 0.82.1" />
<link rel="alternate" type="application/rss&#43;xml" href="/index.xml">
<meta property="og:title" content="" />
<meta property="og:description" content="" />

Expected behavior:

It should be

<link rel="alternate" type="application/rss&+xml" href="/index.xml">

Additional context

The implementation is exactly as specified in the docs:

Potential fix

This does work on

<atom:link href="/categories/index.xml" rel="self" type="application/rss+xml" />

which is generated differently.
The same can be done in head.html with

{{ printf "<link rel=%q type=%q href=%q>" .Rel .MediaType .Permalink | safeHTML }}
@JannikArndt JannikArndt added the bug Something isn't working label May 1, 2021
@adityatelange
Copy link
Owner

adityatelange commented May 1, 2021

This is weird.
As you said - The implementation is exactly as specified in the docs.
Don't you think this should be reported to HUGO?

Also what I see is &#43; is HTML code for + and looks fine in chrome dev tools and after saving the page as HTML.
This can be easily fixed by .MediaType.Type | html

{{ range .AlternativeOutputFormats -}}
<link rel="{{ .Rel }}" type="{{ .MediaType.Type }}" href="{{ .Permalink | safeURL }}">
{{ end -}}

@JannikArndt
Copy link
Contributor Author

Don't you think this should be reported to HUGO?

Probably, but I didn't have time to dive that deep 😅

This can be easily fixed by .MediaType.Type | html

Aaahhh I tried safeURL and safeHTML 🙈 I updated #393 to use this smaller change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants