Loading

Author Topic: RICH EDIT OPTIONS  (Read 503 times)

fer0366

  • Newbie
  • *
  • Posts: 8
    • Email
RICH EDIT OPTIONS
« on: January 25, 2012, 07:11:09 pm »
habilité este Plugin, pero cuando intento insertar en el texto de un Aviso, un Link, desde la opciòn correspondiente, se abre una ventanita en la cual completo los datos, la cierro ... me posiciono sobre la palabra que abre el Link, y veo que està todo bien.
Pero al guardar los cambios del Aviso,  no sè por què se pierde la referencia al Link que ya estaba grabado.
En lugar del Link,  aparece:   %5C

Intenté ya varias veces modificarlo, pero siempre vuelve a perder la referencia correspondiente,  tanto el Link, como el Título que le habìa colocado.

Me resultaría útil poder utilizar esta opción, para citar Páginas Web desde el aviso.

Agradeceré me digan si tiene Solución.

Gracias, Fernando.

_CONEJO

  • Administrator
  • Hero Member
  • *****
  • Posts: 1922
Re: RICH EDIT OPTIONS
« Reply #1 on: January 30, 2012, 11:37:31 am »
Hola fer0366,

¿Qué versión de OSClass utilizas? Recientemente incluimos algún código para aumentar la seguridad y puede ser que sea eso lo que esté borrando los enlaces de texto.


Saludos

fer0366

  • Newbie
  • *
  • Posts: 8
    • Email
Re: RICH EDIT OPTIONS
« Reply #2 on: January 30, 2012, 06:18:58 pm »
estoy utilizando la última versión 2.3.5, y es la primera vez que utilizo el Sistema, recién hace un mes ... y estoy todavía configurando y dando de Alta los primeros Avisos.
Pero con este plugin, que tambièn acabo de instalarlo, me está pasando eso.  Me pierde la relación con links a páginas e imágenes.

No me sucede lo mismo cuando agrego Widgets desde la opción de Apariencia de OSCLass,  donde también se utiliza un Editor HTML.
en ese, los links los mantiene bien.

Alguna recomendación ?

_CONEJO

  • Administrator
  • Hero Member
  • *****
  • Posts: 1922
Re: RICH EDIT OPTIONS
« Reply #3 on: January 30, 2012, 06:31:49 pm »
Hola fer0366,


La solución rápida (pero que no aconsejo) es que modifiques el archivo oc-includes/osclass/core/Params.php

busques (linea 31 y 85 aproximadamente, tengo el archivo modificado y no sabría decirte las líneas exactas)
static function getParam($param, $htmlencode = false, $xss_check = true)
y
static function getParamsAsArray($what = "", $xss_check = true)

y cambies $xss_check = true por $xss_check = false en ambos casos
Con eso debería de permitir los enlaces otra vez.



¡¡¡CUIDADO!!! Con esto quitas todo el chequeo de HTML y permites ataques XSS en tu sitio. En la próxima versión el asunto debería estar solucionado.


También puedes cambiar todo el archivo por esto :


<?php if ( ! defined('ABS_PATH')) exit('ABS_PATH is not loaded. Direct access is not allowed.');

    
/*
     *      OSCLass – software for creating and publishing online classified
     *                           advertising platforms
     *
     *                        Copyright (C) 2010 OSCLASS
     *
     *       This program is free software: you can redistribute it and/or
     *     modify it under the terms of the GNU Affero General Public License
     *     as published by the Free Software Foundation, either version 3 of
     *            the License, or (at your option) any later version.
     *
     *     This program is distributed in the hope that it will be useful, but
     *         WITHOUT ANY WARRANTY; without even the implied warranty of
     *        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     *             GNU Affero General Public License for more details.
     *
     *      You should have received a copy of the GNU Affero General Public
     * License along with this program.  If not, see <http://www.gnu.org/licenses/>.
     */


    
class Params
    
{
        
        private static 
$purifier;
        
        function 
__construct() { }

        static function 
getParam($param$htmlencode false$xss_check true)
        {
            if (
$param == "") return '' ;
            if (!isset(
$_REQUEST[$param])) return '' ;

            if(
$xss_check==true && !isset(self::$purifier)) {
                require_once 
LIB_PATH 'htmlpurifier/HTMLPurifier.auto.php';
                
$config HTMLPurifier_Config::createDefault();
                
$config->set('HTML.Allowed''b,strong,i,em,u,a[href|title],ul,ol,li,p[style],br,span[style]');
                
$config->set('CSS.AllowedProperties''font,font-size,font-weight,font-style,font-family,text-decoration,padding-left,color,background-color,text-align');
                
$config->set('Cache.SerializerPath'ABS_PATH 'oc-content/uploads');
                
self::$purifier = new HTMLPurifier($config);
            }
            
            
$value $_REQUEST[$param];

            if (!
is_array($value)) {
                if(
$xss_check) {
                    
$value self::$purifier->purify($_REQUEST[$param]);
                }
                if (
$htmlencode) {
                    return 
htmlspecialchars(stripslashes($value), ENT_QUOTES);
                }
            } else {
                if(
$xss_check) {
                    foreach(
$value as $k => $v) {
                        
$value[$k] = self::$purifier->purify($v);
                    }
                }
            }

            if(
get_magic_quotes_gpc()) {
                
$value strip_slashes_extended($value);
            }

            return (
$value);
        }

        static function 
existParam($param) {
            if (
$param == "") return false ;
            if (!isset(
$_REQUEST[$param])) return false ;
            return 
true;
        }

        static function 
getFiles($param)
        {
            if (isset(
$_FILES[$param])) {
                return (
$_FILES[$param]);
            } else {
                return 
"";
            }
        }

        
//$what = "post, get, cookie"
        
static function getParamsAsArray($what ""$xss_check true)
        {
            switch (
$what) {
                case(
"get"):    
                    
$value $_GET;
                break;
                case(
"post"):   
                    
$value $_POST;
                break;
                case(
"cookie"):
                    return 
$_COOKIE;
                break;
                default:        
                    
$value $_REQUEST;
                break;
            }
            
            if(
$xss_check==true) {
                if(!isset(
self::$purifier)) {
                    require_once 
LIB_PATH 'htmlpurifier/HTMLPurifier.auto.php';
                    
$config HTMLPurifier_Config::createDefault();
                    
$config->set('HTML.Allowed''b,strong,i,em,u,a[href|title],ul,ol,li,p[style],br,span[style]');
                    
$config->set('CSS.AllowedProperties''font,font-size,font-weight,font-style,font-family,text-decoration,padding-left,color,background-color,text-align');
                    
$config->set('Cache.SerializerPath'ABS_PATH 'oc-content/uploads');
                    
self::$purifier = new HTMLPurifier($config);
                }
                foreach(
$value as $k => $v) {
                    
$value[$k] = self::$purifier->purify($v);
                }
            }
            if(
get_magic_quotes_gpc()) {
                return 
strip_slashes_extended($value);
            }
            return 
$value;
        }

        static function 
setParam($key$value)
        {
            
$_REQUEST[$key] = $value;
            
$_GET[$key] = $value;
            
$_POST[$key] = $value;
        }

        static function 
_view() {
            
print_r(self::getParamsAsArray()) ;
        }
    }

?>

Que es la nueva versión del archivo y "en teoría" no debería fallar


Mi consejo es que pruebes primero sustituyendo todo el archivo, y si no funciona, cambia $xss_check de true a FALSE


Saludos

sstef25

  • Jr. Member
  • **
  • Posts: 68
    • Email
Re: RICH EDIT OPTIONS
« Reply #4 on: February 02, 2012, 11:29:14 pm »
Hi _CONEJO!

I have the same problem with the links and I found this post (i'm reading with google translate :D ).
If i understood correctly, to get this fixed, i have to change the code in Params.php file with the code you wrote, right? but my Params.php has that exact code (i'm using osclass 2.3.5, don't have the rich-edit plugin installed) .... and my links are messed up...

But if i change $xss_check from true to false, the links are working! I understood that this is not so ok to do?
Please, what is the way to "repair" my links?

Thanks,
Stefan



« Last Edit: February 02, 2012, 11:31:12 pm by sstef25 »

_CONEJO

  • Administrator
  • Hero Member
  • *****
  • Posts: 1922
Re: RICH EDIT OPTIONS
« Reply #5 on: February 03, 2012, 11:27:05 am »
Hi sstef45,

Yes more, exactly that. Please, try with this new version. I checked personally and link on rich edit are working fine :



<?php if ( ! defined('ABS_PATH')) exit('ABS_PATH is not loaded. Direct access is not allowed.');

    
/*
     *      OSCLass – software for creating and publishing online classified
     *                           advertising platforms
     *
     *                        Copyright (C) 2010 OSCLASS
     *
     *       This program is free software: you can redistribute it and/or
     *     modify it under the terms of the GNU Affero General Public License
     *     as published by the Free Software Foundation, either version 3 of
     *            the License, or (at your option) any later version.
     *
     *     This program is distributed in the hope that it will be useful, but
     *         WITHOUT ANY WARRANTY; without even the implied warranty of
     *        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     *             GNU Affero General Public License for more details.
     *
     *      You should have received a copy of the GNU Affero General Public
     * License along with this program.  If not, see <http://www.gnu.org/licenses/>.
     */

    
require_once LIB_PATH 'htmlpurifier/HTMLPurifier.auto.php';
    
    class 
Params
    
{    
        private static 
$purifier;
        private static 
$config;
        
        function 
__construct() { }

        static function 
getParam($param$htmlencode false$xss_check true)
        {
            if (
$param == "") return '' ;
            if (!isset(
$_REQUEST[$param])) return '' ;

            
$value self::_purify($_REQUEST[$param], $xss_check) ;

            if (
$htmlencode) {
                return 
htmlspecialchars(stripslashes($value), ENT_QUOTES);
            }

            if(
get_magic_quotes_gpc()) {
                
$value strip_slashes_extended($value);
            }

            return (
$value);
        }

        static function 
existParam($param)
        {
            if (
$param == "") return false ;
            if (!isset(
$_REQUEST[$param])) return false ;
            return 
true;
        }

        static function 
getFiles($param)
        {
            if (isset(
$_FILES[$param])) {
                return (
$_FILES[$param]);
            }

            return 
"";
        }

        
//$what = "post, get, cookie"
        
static function getParamsAsArray($what ""$xss_check true)
        {
            switch (
$what) {
                case(
"get"):    
                    
$value $_GET;
                break;
                case(
"post"):   
                    
$value $_POST;
                break;
                case(
"cookie"):
                    return 
$_COOKIE;
                break;
                default:        
                    
$value $_REQUEST;
                break;
            }

            
$value self::_purify($value$xss_check) ;

            if(
get_magic_quotes_gpc()) {
                return 
strip_slashes_extended($value) ;
            }

            return 
$value;
        }

        static function 
setParam($key$value)
        {
            
$_REQUEST[$key] = $value;
            
$_GET[$key] = $value;
            
$_POST[$key] = $value;
        }

        static function 
_view()
        {
            
print_r(self::getParamsAsArray()) ;
        }

        static private function 
_purify($value$xss_check)
        {
            
self::$config HTMLPurifier_Config::createDefault();
            
$allowed 'b,strong,i,em,u,a[href|title],ul,ol,li,p[style],br,span[style],img[width|height|alt|src],';
            
$allowed .= 'object[align<bottom?left?middle?right?top|archive|border|class|classid|codebase|codetype|data|';
            
$allowed .= 'declare|dir<ltr?rtl|height|hspace|id|lang|name|onclick|ondblclick|onkeydown|onkeypress|onkeyup|';
            
$allowed .= 'onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|standby|style|tabindex|title|type|usemap|vspace|width]';
            
self::$config->set('HTML.Allowed'$allowed);
            
self::$config->set("HTML.SafeEmbed"true);
            
self::$config->set("HTML.SafeObject"true);
            
self::$config->set('CSS.AllowedProperties''font,font-size,font-weight,font-style,font-family,text-decoration,padding-left,color,background-color,text-align');
            
self::$config->set('Cache.SerializerPath'ABS_PATH 'oc-content/uploads');

            if( !
$xss_check ) {
                return 
$value ;
            }

            if( !isset(
self::$purifier) ) {
                
self::$purifier = new HTMLPurifier(self::$config);
            }

            if( 
is_array($value) ) {
                foreach(
$value as $k => &$v) {
                    
$v self::_purify($v$xss_check) ;
                }
            } else {
                
$value self::$purifier->purify($value) ;
            }

            return 
$value ;
        }
    }

?>



Tell me if you have any problem downloading it.


what $xss_check does is to perform some check and security against xss attacks. Not enabling it could be a serious problem, that under certain situations could reveal security information.


Thanks

sstef25

  • Jr. Member
  • **
  • Posts: 68
    • Email
Re: RICH EDIT OPTIONS
« Reply #6 on: February 03, 2012, 01:09:09 pm »
Hi _CONEJO

Sorry, my mistake - i wasn't clear - i do not have rich edit plugin instaled, i don't use it.... i have the same problem with the links changing to %5C but to all the links on the custom pages....

There are a couple of topics opened about that, here: http://forums.osclass.org/general-help/links-in-pages/ and here: http://forums.osclass.org/development/my-links-on-page-do-not-work/

Anyway, i changed the Params.php with the code you gave me but still nothing.... every link i insert it's changed to %5C !!

Please, maybe you can take a look and find a solution?

Thanks,
Stefan

_CONEJO

  • Administrator
  • Hero Member
  • *****
  • Posts: 1922
Re: RICH EDIT OPTIONS
« Reply #7 on: February 03, 2012, 01:32:30 pm »
Hi,

That's strange, I'm sure that next version will be working, but not sure why it does not work for you.

« Last Edit: February 03, 2012, 01:52:54 pm by _CONEJO »

sstef25

  • Jr. Member
  • **
  • Posts: 68
    • Email
Re: RICH EDIT OPTIONS
« Reply #8 on: February 03, 2012, 01:57:13 pm »
Hi,

that was quick! : :) Thanks a lot!!! I'll try it right now and give feedback... thansk again!!

Regarding the %5C issue...  i myself hoped that maybe the next upgrade will fix it so i leaved it like this until then....

If i may, (hope i'm not asking too much :) ), could you please take a quick look here and tell me your opinion: http://forums.osclass.org/general-help/can't-see-the-items-in-admin/

Thanks a lot,
Stefan

adsjapan

  • Newbie
  • *
  • Posts: 16
    • ADs Japan
Re: RICH EDIT OPTIONS
« Reply #9 on: April 11, 2012, 10:12:41 am »
That worked. Thanks.
http://adsjapan.net/  - Created using OSClass
http://jkaihatsu.com/ - My personal blog