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

Allow special characters #34

Closed
microcipcip opened this issue Dec 4, 2016 · 12 comments · Fixed by #35
Closed

Allow special characters #34

microcipcip opened this issue Dec 4, 2016 · 12 comments · Fixed by #35
Labels

Comments

@microcipcip
Copy link

Hi, how do you allow special characters?
For example, if you have This is my title's, it will render as This is my title's which doesn't rendere correctly in the title tag

@zspecza
Copy link
Contributor

zspecza commented Dec 5, 2016

Hi @microcipcip - use __dangerouslyDisableSanitizers:

{
  metaInfo: {
    ...
    __dangerouslyDisableSanitizers: ['title']
  }
}

I should probably ponder the notion of making the sanitizers a little more lenient of certain characters and only sanitize HTML-relevant symbols like /, < and >. Happy to discuss.

@microcipcip
Copy link
Author

Yes, that would be great, symbols like & and hyphen are quite common in the <title> and the meta tags :)

@microcipcip
Copy link
Author

I've open this again as I guess it should be discussed more, as the alternative ATM seems to be using that long function or use lodash unescape. I guess that that function is set globally and not for each component?

@zspecza
Copy link
Contributor

zspecza commented Dec 6, 2016

@microcipcip you're correct - since any deeply nested component overwrites it's parent metaInfo. I can't think of a use-case for per-component sanitization, and it would complicate things a little - but if there's a use for it, I'll consider it.

@microcipcip
Copy link
Author

I guess that a global setting is what I need in this case, better than use __dangerouslyDisableSanitizers in 20 components :)

@zspecza zspecza added the bug label Dec 7, 2016
@zspecza
Copy link
Contributor

zspecza commented Dec 7, 2016

I've dug more into this:

When server rendering, if meta charset='utf-8' is present, the correct title is displayed.
This is not true for a client render, as JavaScript does not understand HTML entity encoding, but rather character codes in the form of hexadecimal identifiers.

This means that escaping content on the client side does not currently work as intended. This is therefore a bug.

I'm looking into various ways to handle this issue, but so far all the methods I have found are either hacks or open XSS vulnerabilities. I'll keep looking.

@zspecza
Copy link
Contributor

zspecza commented Dec 7, 2016

Hi @microcipcip - I've added a fix for this, could you update vue-meta & remove your __dangerouslyDisableSanitizers config and confirm if it works for you?

@microcipcip
Copy link
Author

Thanks, I'll update it this evening when I get back from work :)

@microcipcip
Copy link
Author

Hey, it works great, thanks a lot!

@equinusocio
Copy link

equinusocio commented Jul 27, 2019

@declandewet I have same issue with meta tags. I have an og:image from CDN with query string that is escaped and so invalidated:

https://images.ctfassets.net/gz0sygvqczyz/2d5wlYciwkwLpvGlSMc8Eg/914a2626b91bbd41fe630238858c74a8/AR.png?fit=pad&f=top&w=1200&h=630&bg=rgb:F3F6F9

become

https://images.ctfassets.net/gz0sygvqczyz/2d5wlYciwkwLpvGlSMc8Eg/914a2626b91bbd41fe630238858c74a8/AR.png?fit=pad&amp;f=top&amp;w=1200&amp;h=630&amp;bg=rgb:F3F6F9

@aslamdoctor
Copy link

Hey, it works great, thanks a lot!
Can you recall what actions you performed to make this work?

@vedmant
Copy link

vedmant commented Mar 2, 2021

I have the same issue as @equinusocio, it escapes query in the url so url is not working anymore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants