html tags are always stripped in input fields

15 years 7 months ago #75617 by Marblex
After installing I immediately went to check out the Editor Text Area. To see what it could do.

I was surprised to see that it didn't store any HTML at all.
Switching editors and changing the filter settings didn't help either.

I finally traced it down to comprofiler.class.php line 5095
As you can see in the code below. the "if class_exists" appears to fail, defaulting back to a strip_tags instruction.

This is because the class JInputFilter does not exist.
What does exist is JFilterInput
I changed that, and now it works fine.

[code:1]
function clean( $filter, $source, $type='string' ) {

if ( class_exists( "JInputFilter" ) ) {

$result = $filter->clean( $source, $type );

} elseif ( class_exists( "InputFilter" ) ) {

// Handle the type constraint

switch (strtoupper($type))

{

case 'INT' :

case 'INTEGER' :

// Only use the first integer value

@ preg_match('/-?[0-9]+/', $source, $matches);

$result = @ (int) $matches[0];

break;



case 'FLOAT' :

case 'DOUBLE' :

// Only use the first floating point value

@ preg_match('/-?[0-9]+(\.[0-9]+)?/', $source, $matches);

$result = @ (float) $matches[0];

break;



case 'BOOL' :

case 'BOOLEAN' :

$result = (bool) $source;

break;



case 'WORD' :

$result = (string) preg_replace( '#\W#', '', $source );

break;



default :

$result = $this->_process( $filter, $source );

break;

}

} else {

$result = strip_tags( $source ); // sorry, but old mambo versions are unsafe

}

return $result;

}

[/code:1]

Installed Joomla version 1.5.4
Installed CB 1.1

Also..
When I was google searching for part of your code I came across 2 sets of Joomla API documentation, that contradict each other at exactly this point.

So. Do not go here:
docs.huihoo.com/api/joomla/1.5/Joomla-Framework/Filter/JInputFilter.html
But go here:
api.joomla.org/Joomla-Framework/Filter/JFilterInput.html

I'm thinking it's a Chinese conspiracy :)

Please Log in to join the conversation.

15 years 7 months ago #75621 by beat
Thanks for sharing the solution for CB 1.1. B)

This and many other API changes of Joomla 1.5 are already fixed in CB 1.2 RC 2. :)

Beat - Community Builder Team Member

Before posting on forums: Read FAQ thoroughly -- Help us spend more time coding by helping others in this forum, many thanks :)
CB links: Our membership - CBSubs - Templates - Hosting - Forge - Send me a Private Message (PM) only for private/confidential info

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.247 seconds

Facebook Twitter LinkedIn