项目作者: avoskitchen

项目描述 :
Sanitize and filter untrusted HTML input in Kirby 3
高级语言: PHP
项目地址: git://github.com/avoskitchen/kirby-sanitizer.git
创建时间: 2020-05-07T23:00:00Z
项目社区:https://github.com/avoskitchen/kirby-sanitizer

开源协议:GNU Lesser General Public License v2.1

下载


Sanitizer Plugin for Kirby

Handle untrusted user input, e.g. in comments or any other user-submitted form with
confidence. The Sanitizer plugin escaped all unsafe HTML tags, corrects illegally
nested HTML tags and syntax errors, while keeping a small, well-formed subset of
all the HTML tags in existance. Optionally, Markdown can also be enabled.

Installation

Download

Download and copy this repository to /site/plugins/kirby-sanitizer.

Git submodule

  1. git submodule add https://github.com/avoskitchen/kirby-sanitizer.git site/plugins/kirby-sanitizer

Composer

  1. composer require avoskitchen/kirby-sanitizer

Setup

Use the provided helper function sanitize(string $html, array $options = []) in your
templates or anywhere else, where you need for sanitize untrusted HTML input. You can
also use the corresponding field method $field->sanitize(array $options = []).

Options

Key Default value Description
dir null Sets the text direction of the input HTML. If null, the current locale setting of Kirby is used.
markdown false Parse Markdown commands before sanitization.
smartypants null If not specified, Kirby’s default setting is used.
allowlinks true Allow links in output HTML.
autolinks true Automatically convert all URLs to links. If allowlinks is set to false, this option has no effect.
headingClass {{ tag }}-sanitized Class to apply to replaced headlines. Available playeholders: {{ tag }} = The full tag name of the replaced (<h[1-6]>) element / {{ level }} = The level ([1-6]) of the replaced element.

You can set global defaults, by prepending any of the options above with the plugin namespace (avoskitchen.sanitizer):

  1. # site/config/config.php
  2. return [
  3. 'avoskitchen.sanitizer.allowlinks' => false,
  4. ];

Development

I created this plugin for my own purposes. I will try my best if you report a bug, but
if you need any new features, please be aware that I don’t really have time to develop
them for your needs. But you are welcome to support the development of this plugin by
contributing code. I’m happy to help you with that, if I can.

License

LPGL

Credits

Third-party Libraries