HTML tags on PHP 7 broken?

Started by CreativeITWorld.com, July 15, 2018, 02:07:59 AM

Previous topic - Next topic

CreativeITWorld.com

Quote from: Aleksi "Lex" Kilpinen on March 22, 2018, 03:10:43 AM

[html]<script src="https://xxx-xxx-dna-ssl.com/js/1/form?key=PxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxY&form=heatpump"></script>
<div id="heatpump-form"></div>[/html]


HTML BBC no longer works in PHP7

Aleksi "Lex" Kilpinen

Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

How you can help SMF

CreativeITWorld.com

I went back to PHP5.6 and it worked perfectly.

Forward again to PHP7 and failure.

QuoteThe following error or errors occurred while posting this message:
The message body was left empty.

All previously made posts using PHP5.6 with the HTML BBC remain and work fine. It's just trying to post with PHP7 that brings up the error.

Aleksi "Lex" Kilpinen

Could you check your server error log, does trying to use the HTML tags leave any entry in there?
Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

How you can help SMF

CreativeITWorld.com

Nothing about it in the Error Log.

Even after Pruning, the Error Log remains empty after attempting and failing to post using the HTML BBC.

Aleksi "Lex" Kilpinen

What code are you testing with?
Are you using WYSIWYG or not?
What version of SMF are you on?
Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

How you can help SMF

CreativeITWorld.com

Using an iframe. Tested without the iframe and including other codes until down to the bare HTML BBC and it's still the same no matter what.

WYSIWYG turned off.
SMF 2.0.15

Aleksi "Lex" Kilpinen

I'll be testing this, may take a while. In the meantime if someone can replicate this behaviour, please feel free to jump in :)
Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

How you can help SMF

Arantor


CreativeITWorld.com

Thank you. It does seem easy to replicate. Just switch between PHP7 and PHP5.6 using .htaccess.

I have an idea where the problem is, but I don't know how to rectify it.

I expect Subs-Post.php in the Line 235 region.

My assumption is that something there is incompatible with PHP7.

Quote from: Arantor on July 15, 2018, 05:06:26 AM
How does it "not work"?

Refuses the post by producing the following error notification:

The following error or errors occurred while posting this message:
The message body was left empty.

Arantor


CreativeITWorld.com

Half a million mods ... well 69 of them. Too many to list.

We'll see first if it can be replicated. As the error only occurs with the change to PHP7 and is removed when switching back to PHP5.6, I expect the error will be replicated. If not, I know how it is, it'll be a problem with the mods.

And if it is replicated, the problem will be fixed in a future update.

Arantor

I'm literally one of the people who made SMF 2.0 work on PHP 7. This was tested when first built, and it worked for me when we rewrote that section for the changes in PHP 5.5, which haven't changed in PHP 7.

In addition other users report it works on 7.1 for them. So it comes back to whatever mods you have that change this code.

If you don't want to lis all the mods because selecting all the text and copy paste is too hard (even though we have users with over 200 mods who don't have this problem), you could at least attach Subs-Post so one of us who knows the code can take a look.

Aleksi "Lex" Kilpinen

Tested on PHP 7.0.29 ( FPM ) with both a vanilla 2.0.15 and 2.1 beta 3, using the following

[html]<img src="https://smf.domain.tld/Themes/default/images/smflogo.png" /> [/html]


Saw no issues.
Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

How you can help SMF

CreativeITWorld.com

200 mods. LOL And I thought I had a lot at 69.

The mod that could but shouldn't be causing the error is ...

[HTML] Permission Mod



<id>winrules:[HTML]Permission</id>
<version>2.0</version>


<file name="$sourcedir/Subs-Post.php">

<operation>
<search position="replace"><![CDATA[
if (allowedTo('admin_forum'))
]]></search>
<add><![CDATA[
if (allowedTo('post_html'))
]]></add>
</operation>

</file>


<file name="$languagedir/ManagePermissions.english.php">
<operation>
<search position="replace"><![CDATA[
$txt['permissiongroup_attachment'] = 'Attachments';
]]></search>
<add><![CDATA[
$txt['permissionname_post_html'] = 'Post HTML';
$txt['permissionhelp_post_html'] = 'This will allow members to post HTML using [html] BBC tags.';

$txt['permissiongroup_attachment'] = 'Attachments';
]]></add>
</operation>

</file>

CreativeITWorld.com

Quote from: Aleksi "Lex" Kilpinen on July 15, 2018, 05:35:17 AM
Tested on PHP 7.0.29 ( FPM ) with both a vanilla 2.0.15 and 2.1 beta 3, using the following

[html]<img src="https://smf.domain.tld/Themes/default/images/smflogo.png" /> [/html]


Saw no issues.

Then it must be one of my mods most probably affecting Subs-Post.php.

Thanks for checking.

Aleksi "Lex" Kilpinen

Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

How you can help SMF

CreativeITWorld.com

Again, thanks for checking, which allowed me to move to the next level of testing.

I replaced the following code in my Subs-Post.php

$parts[$i] = preg_replace('~\[html\](.+?)\[/html\]~ise', '\'[html]\' . strtr(un_htmlspecialchars(\'$1\'), array("\n" => \'\', \'  \' => \'  \', \'[\' => \'[\', \']\' => \']\')) . \'[/html]\'', $parts[$i]);


With the following from the latest fresh download of SMF 2.0.15
{
static $htmlfunc = null;
if ($htmlfunc === null)
$htmlfunc = create_function('$m', 'return \'[html]\' . strtr(un_htmlspecialchars("$m[1]"), array("\n" => \'\', \'  \' => \'  \', \'[\' => \'[\', \']\' => \']\')) . \'[/html]\';');
$parts[$i] = preg_replace_callback('~\[html\](.+?)\[/html\]~is', $htmlfunc, $parts[$i]);
}


It appears to me as if an Update was needed for that area at one time and was not applied. I've been running it since 1.whatever.

If I can, I'll mark this topic as solved.

Arantor

Ah, that particular line of code should have been updated in 2.0.7 and 2.0.8 - because that code was officially deprecated (the e option in the regex) in 5.5 and removed in 7.0.

Aleksi "Lex" Kilpinen

I will not link to the forum in question - but if I have it right, I wish to point out that you have apparently on purpose hidden the SMF copyright, along with many other copyright statements, by changing the font size of them to 0px.

In the case of SMF copyright, this is legal but we reserve the right to deny support from those who choose to do this.
In the case of all the other hidden copyright statements, you may actually be in breach of their licensing terms, and I would kindly request you consider fixing this. 


<span class="smalltext" style="display: inline; visibility: visible; font-family: Verdana, Arial, sans-serif;"><a href="https://(domain withheld)/forum/index.php?action=credits" title="Simple Machines Forum" target="_blank" class="new_win">SMF</a> |
<a href="http://www.simplemachines.org/about/smf/license.php" title="License" target="_blank" class="new_win">SMF &copy; 2017</a>, <a href="http://www.simplemachines.org" title="Simple Machines" target="_blank" class="new_win">Simple Machines</a><br /><a href="http://www.smfhacks.com/menu-editor-pro.php">Menu Editor Pro 1.0</a> | <a href="http://labradoodle-360.com/">Copyright 2013, Matthew Kerle</a><br /><a href="http://www.createaforum.com" target="_blank">Simple Audio Video Embedder</a><br /><span class="smalltext">Enotify by <a href="http://www.createaforum.com" title="Forum Hosting">CreateAForum.com</a></span><br /><a target="_blank" href="http://www.tinyportal.net" title="TinyPortal">TinyPortal</a> <a href="https://(domain withheld)/forum/index.php?action=tpmod;sa=credits" title="TP 1.5.0">&copy; 2005-2018</a>

Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

How you can help SMF

Advertisement: