ampReplace() changed in Joomla.php

Joomla version 1.0 is end-of-life and are no longer supported. Please use Joomla 3.x instead.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Locked
kat_smith
Joomla! Apprentice
Joomla! Apprentice
Posts: 8
Joined: Mon Jun 26, 2006 12:14 am

ampReplace() changed in Joomla.php

Post by kat_smith » Thu Jun 29, 2006 1:58 am

After migrating from Mambo 4.5.2 to Joomla! 1.0.9 I got an error from the ampReplace function. I have a standard Javascript Flash detect script in content (inside HTMLfix tags). This part:

var MM_contentVersion = 6;
.
.
.
if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0 && (navigator.appVersion.indexOf("Win") != -1)) {
document.write('\n'); //FS hide this from IE4.5 Mac by splitting the tag
document.write('on error resume next\n');
document.write('MM_FlashCanPlay = ( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & MM_contentVersion)))\n');
document.write('\n');
}

becomes:

var MM_contentVersion = 6;
.
.
.
if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0 && (navigator.appVersion.indexOf("Win") != -1)) {
document.write('\n'); //FS hide this from IE4.5 Mac by splitting the tag
document.write('on error resume next\n');
document.write('MM_FlashCanPlay = ( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & MM_contentVersion)))\n');
document.write('\n');
}

because of this line:

function ampReplace( $text ) {
$text = str_replace( '&&', '*--*', $text );
$text = str_replace( '&#', '*-*', $text );
$text = str_replace( '&', '&', $text );
$text = preg_replace( '|&(?![\w]+;)|', '&', $text ); // this is the line causing problems
$text = str_replace( '*-*', '&#', $text );
$text = str_replace( '*--*', '&&', $text );
return $text;
}

& is a VB script bitwise AND operator; + will concatenate two strings so I got round the error by making these changes:

var MM_contentVersion = "6";
.
.
.
if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0 && (navigator.appVersion.indexOf("Win") != -1)) {
document.write('\n'); //FS hide this from IE4.5 Mac by splitting the tag
document.write('on error resume next\n');
document.write('MM_FlashCanPlay = ( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." + MM_contentVersion)))\n');
document.write('\n');
}

User avatar
tyler
Joomla! Intern
Joomla! Intern
Posts: 71
Joined: Thu Jan 26, 2006 11:36 pm
Location: Los Angeles, California, United States
Contact:

Re: ampReplace() changed in Joomla.php

Post by tyler » Sun Jul 02, 2006 12:47 am

I had the exact same problem after upgrading to v1.0.10, and I actually have a better solution than commenting out the line in joomla.php

This problem is better resolved by commenting the culprit line in components/com_content/content.html.php

find this line around line 519 (in v1.0.10):

Code: Select all

echo ampReplace( $row->text );
and replace it with:

Code: Select all

echo $row->text;
//echo ampReplace( $row->text );
It is overzealous to be using ampReplace() on $row->text since that variable is often the actual verbiage within the content and therefore should not necessarily be subject to all the xhtml compliance requirements.  Links, formatting related texts, and other types of input texts intended more for the browser should be ampReplaced appropriately, but not the author/user texts which is what is primarily represented by the $row->text variable... and subsequently javascripts which the webmaster may embed with the expectation that the JS code remain unstripped for the purpose of working properly.
Last edited by tyler on Sun Jul 02, 2006 1:17 am, edited 1 time in total.
-Tyler D.
Web Developer & Integrator: http://www.LasVegasExtremes.com


Locked

Return to “Upgrading - 1.0.x”