Giter Club home page Giter Club logo

Comments (7)

vlad-ghita avatar vlad-ghita commented on July 28, 2024

It is supported, but not documented. Forgot about it ...

You can set filters on __filters key from your section array:

$_POST['sections']['news']['__filters'] = array('xss', 'etm-new-mail')

You can do it Frontend but I highly recommend doing it in a custom event. The priority of Sections Event is set to LOW, but I recommend setting your custom event priority to HIGH.

from sections_event.

lewiswharf avatar lewiswharf commented on July 28, 2024

You can do it Frontend but I highly recommend doing it in a custom event.

Why recommend a custom event?

from sections_event.

vlad-ghita avatar vlad-ghita commented on July 28, 2024

Update: 10 may 2013: Fixed code to actually work.

You can set the filter in the Frontend like this:

<input name="sections[news][__filters][]" type="hidden" value="xss"/>
<input name="sections[news][__filters][]" type="hidden" value="etm-new-mail"/>

But you are vulnerable to DOM hijack.

So I recommend a custom event which simply sets the filter values in PHP:

public static function allowEditorToParse(){
    return false;
}

public function priority(){
    return self::kHIGH;
}

public function load(){
    if( !isset($_REQUEST['action']['sections']) ) return;

    $_REQUEST['sections']['news']['__filters'] = array(
        'etm-new-mail',
        'xss-fail'
    );
}

from sections_event.

lewiswharf avatar lewiswharf commented on July 28, 2024

I've never thought about using an event in this way. Brilliant.

from sections_event.

patrickyan avatar patrickyan commented on July 28, 2024

Wow found this randomly. Filters work fine with the <input> for me, but I can't get it working with the event

This is what I have.

<?php

    require_once(TOOLKIT . '/class.event.php');

    Class eventsend_message_notification extends SectionEvent{

        public $ROOTELEMENT = 'send-message-notification';

        public $eDefaultValues = array(
        );

        public static function about(){
            return array(
                'name' => 'Send message notification',
                'author' => array(
                    'name' => 'Patrick Yan',
                    'website' => 'http://local.crashdwell.com:8888',
                    'email' => '[email protected]'),
                'version' => 'Symphony 2.3.2',
                'release-date' => '2013-04-12T02:55:54+00:00'
            );
        }

    public static function allowEditorToParse(){
        return false;
    }

    public function priority(){
        return self::kHIGH;
    }

    public function execute(){
        $_POST['sections']['messages']['__filters'] = array(
          'etm-new-message',
          'xss-fail'
        );

        return false;
    }

    public function load(){
    }

    }

from sections_event.

vlad-ghita avatar vlad-ghita commented on July 28, 2024

I'll have a look this weekend.

from sections_event.

vlad-ghita avatar vlad-ghita commented on July 28, 2024

@patrickyan I uploaded the code example in my above comment b/c it was flawed. The code you need should stay in the load() method, not execute(). In your case, this is what you need:

<?php

    require_once(TOOLKIT . '/class.event.php');

    Class eventsend_message_notification extends Event{

        public static function about(){
            return array(
                'name' => 'Send message notification',
                'author' => array(
                    'name' => 'Patrick Yan',
                    'website' => 'http://local.crashdwell.com:8888',
                    'email' => '[email protected]'),
                'version' => 'Symphony 2.3.2',
                'release-date' => '2013-04-12T02:55:54+00:00'
            );
        }

        public static function allowEditorToParse(){
            return false;
        }

        public function priority(){
            return self::kHIGH;
        }

        public function load(){
            if( !isset($_REQUEST['action']['sections']) ) return;

            $_REQUEST['sections']['messages']['__filters'] = array(
              'etm-new-message',
              'xss-fail'
            );
        }
    }

from sections_event.

Related Issues (15)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.