Development > Bugs

Shoutbox can't refresh on non utf-8 languages

(1/3) > >>

ataru:
referring to:
http://simpleportal.net/index.php?topic=10356.0
and
http://simpleportal.net/index.php?topic=13840.0

i found that in Portalshoutbox.template.php the use of htmlspecialchars for non utf-8 languages, due to php 5.4, generates empty values in xml, so that shoutboxes can't refresh when xml is compiled with special chars:

--- Code: ---function template_shoutbox_xml()
{
global $context, $txt, $smcFunc;

echo '<', '?xml version="1.0" encoding="', $context['character_set'], '"?', '>
<smf>
<shoutbox>', $context['SPortal']['shoutbox']['id'], '</shoutbox>';

if ($context['SPortal']['updated'])
{
echo '
<updated>1</updated>
<error>', empty($context['SPortal']['shouts']) ? $txt['sp_shoutbox_no_shout'] : 0, '</error>
<warning>', !empty($context['SPortal']['shoutbox']['warning']) ? $smcFunc['htmlspecialchars']($context['SPortal']['shoutbox']['warning']) : 0, '</warning>
<reverse>', !empty($context['SPortal']['shoutbox']['reverse']) ? 1 : 0, '</reverse>';

foreach ($context['SPortal']['shouts'] as $shout)
echo '
<shout>
<id>', $shout['id'], '</id>
<author>', htmlspecialchars($shout['author']['link']), '</author>
<time>', htmlspecialchars($shout['time']), '</time>
<timeclean>', htmlspecialchars(strip_tags($shout['time'])), '</timeclean>
<delete>', !empty($shout['delete_link_js']) ? htmlspecialchars($shout['delete_link_js']) : 0, '</delete>
<content>', htmlspecialchars($shout['text']), '</content>
<is_me>', $shout['is_me'] ? 1 : 0, '</is_me>
</shout>';
}
else
echo '
<updated>0</updated>';

echo '
</smf>';

--- End code ---
using $smcFunc['htmlspecialchars'] will fix it. can you consider it in next releases?


--- Code: ---function template_shoutbox_xml()
{
global $context, $txt, $smcFunc;

echo '<', '?xml version="1.0" encoding="', $context['character_set'], '"?', '>
<smf>
<shoutbox>', $context['SPortal']['shoutbox']['id'], '</shoutbox>';

if ($context['SPortal']['updated'])
{
echo '
<updated>1</updated>
<error>', empty($context['SPortal']['shouts']) ? $txt['sp_shoutbox_no_shout'] : 0, '</error>
<warning>', !empty($context['SPortal']['shoutbox']['warning']) ? $smcFunc['htmlspecialchars']($context['SPortal']['shoutbox']['warning']) : 0, '</warning>
<reverse>', !empty($context['SPortal']['shoutbox']['reverse']) ? 1 : 0, '</reverse>';

foreach ($context['SPortal']['shouts'] as $shout)
echo '
<shout>
<id>', $shout['id'], '</id>
<author>', $smcFunc['htmlspecialchars']($shout['author']['link']), '</author>
<time>', $smcFunc['htmlspecialchars']($shout['time']), '</time>
<timeclean>', $smcFunc['htmlspecialchars'](strip_tags($shout['time'])), '</timeclean>
<delete>', !empty($shout['delete_link_js']) ? $smcFunc['htmlspecialchars']($shout['delete_link_js']) : 0, '</delete>
<content>', $smcFunc['htmlspecialchars']($shout['text']), '</content>
<is_me>', $shout['is_me'] ? 1 : 0, '</is_me>
</shout>';
}
else
echo '
<updated>0</updated>';

echo '
</smf>';

--- End code ---

thanks

Raji:
where is this file?
Portalshoutbox.template.php

♦ Ninja ZX-10RR ♦:
A little search would have told you, but it's usually in Themes/default directory ;)

[SiNaN]:
Thank you for the report and suggested fix. I can confirm that that's how it should have been done. This should be fixed in the next version. Until then, those who are having problems may use the suggested fix in the first post.

[SiNaN]:
The fix for this has been committed.

Navigation

[0] Message Index

[#] Next page

Go to full version