By Tony Partridge on Wednesday, 01 March 2017
Posted in Technical Issues
Replies 5
Likes 0
Views 139
Votes 0
Hello,

Ok so when you include say:

img alt="My title" src="https://stackideas.cachefly.net/templates/delta/images/logo-stackideas.png" />

Your meta tags for og:title is rendering the HTML too. It should be stripped.

I've included the example in this post so you can see it happening on your forum. Look at the top of the page now ;-)
Hey Tony,

I've tested on my locally, if you enter the valid HTML code in discussion title e.g. :

Discussion title <img alt="My title" src="https://stackideas.cachefly.net/templates/delta/images/logo-stackideas.png" /> - test


It will strip the HTML tags correctly, so it will show like :

Discussion title - test


If you enter following post title the system will not strip it because this is not valid img html tag:

img alt="My title" src="https://stackideas.cachefly.net/templates/delta/images/logo-stackideas.png"; />


Imagine if the user want to post this kind of HTML attribute as title e..g img, alt, src or etc, it will not show on the post title.
·
Thursday, 02 March 2017 12:45
·
0 Likes
·
0 Votes
·
0 Comments
·
Hello,

As my post states, you are not stripping all. To clarify further special characters in this essence.

So see my attached image this is of this post on this forum. You think that is acceptable?

You should be using a clean up script like this:


$value = strip_tags('img alt="My title" src="https://stackideas.cachefly.net/templates/delta/images/logo-stackideas.png" />');

$clean = preg_replace('/[^A-Za-z0-9]/', ' ', $value);

echo $clean;
·
Thursday, 02 March 2017 17:09
·
0 Likes
·
0 Votes
·
0 Comments
·
Thanks for your suggested code, I will lock this issue into our issue tracker and we will see what we can do about it.

By the way, I'm curious, may i know what is the situation your user enter those html code into post title?
·
Thursday, 02 March 2017 18:22
·
0 Likes
·
0 Votes
·
0 Comments
·
Hello Arlex,

The user was pasting it from his editor into the title.

It messed up the page display on our site because of it. Whilst a slight user error it still posses an issue as it just shouldn't be allowed. Or you should be encoding it on render.

Many thanks
Tony
·
Thursday, 02 March 2017 18:30
·
0 Likes
·
0 Votes
·
0 Comments
·
You're welcome

Thanks for letting us know about it.
·
Thursday, 02 March 2017 18:36
·
0 Likes
·
0 Votes
·
0 Comments
·
View Full Post