{"id":15742854,"url":"https://github.com/bnomei/kirby3-htmlpurifier","last_synced_at":"2025-03-13T09:32:41.002Z","repository":{"id":37531170,"uuid":"246004968","full_name":"bnomei/kirby3-htmlpurifier","owner":"bnomei","description":"Static class method, Uniform-Guard and Field-Method to filter your \"dirty\" HTML inputs to \"clean\" HTML.","archived":false,"fork":false,"pushed_at":"2023-04-20T07:14:53.000Z","size":494,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-11T03:05:32.038Z","etag":null,"topics":["filter","form","headless","html","htmlawed","input","kirby3","kirby3-cms","kirby3-plugin","kql","kses","safe","sanitize","security","striptags","submit","uniform","xss"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bnomei.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":"bnomei","patreon":"bnomei","open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":["https://buymeacoff.ee/bnomei","https://paypal.me/bnomei"]}},"created_at":"2020-03-09T10:23:34.000Z","updated_at":"2023-06-29T04:59:41.000Z","dependencies_parsed_at":"2023-01-23T01:35:12.044Z","dependency_job_id":null,"html_url":"https://github.com/bnomei/kirby3-htmlpurifier","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bnomei%2Fkirby3-htmlpurifier","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bnomei%2Fkirby3-htmlpurifier/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bnomei%2Fkirby3-htmlpurifier/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bnomei%2Fkirby3-htmlpurifier/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bnomei","download_url":"https://codeload.github.com/bnomei/kirby3-htmlpurifier/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221359323,"owners_count":16804780,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["filter","form","headless","html","htmlawed","input","kirby3","kirby3-cms","kirby3-plugin","kql","kses","safe","sanitize","security","striptags","submit","uniform","xss"],"created_at":"2024-10-04T03:01:15.368Z","updated_at":"2025-03-13T09:32:40.996Z","avatar_url":"https://github.com/bnomei.png","language":"PHP","funding_links":["https://github.com/sponsors/bnomei","https://patreon.com/bnomei","https://buymeacoff.ee/bnomei","https://paypal.me/bnomei"],"categories":[],"sub_categories":[],"readme":"# Kirby HtmlPurifier\n\n![Release](https://flat.badgen.net/packagist/v/bnomei/kirby3-htmlpurifier?color=ae81ff)\n![Downloads](https://flat.badgen.net/packagist/dt/bnomei/kirby3-htmlpurifier?color=272822)\n[![Build Status](https://flat.badgen.net/travis/bnomei/kirby3-htmlpurifier)](https://travis-ci.com/bnomei/kirby3-htmlpurifier)\n[![Coverage Status](https://flat.badgen.net/coveralls/c/github/bnomei/kirby3-htmlpurifier)](https://coveralls.io/github/bnomei/kirby3-htmlpurifier) \n[![Maintainability](https://flat.badgen.net/codeclimate/maintainability/bnomei/kirby3-htmlpurifier)](https://codeclimate.com/github/bnomei/kirby3-htmlpurifier) \n[![Twitter](https://flat.badgen.net/badge/twitter/bnomei?color=66d9ef)](https://twitter.com/bnomei)\n\nStatic class method, Uniform-Guard and Field-Method to filter your \"dirty\" HTML inputs to \"clean\" HTML.\n\n[strip_tags](https://www.php.net/manual/en/function.strip-tags.php) and [PHP Input Filter](https://www.phpclasses.org/package/2189-PHP-Filter-out-unwanted-PHP-Javascript-HTML-tags-.html) are not good enough for you? Installing a plugin that has a dependency with lots of code does not bother you? You are willing to take the performance hit if you use it? Read on then...\n\n## Installation\n\n- unzip [master.zip](https://github.com/bnomei/kirby3-htmlpurifier/archive/master.zip) as folder `site/plugins/kirby3-htmlpurifier` or\n- `git submodule add https://github.com/bnomei/kirby3-htmlpurifier.git site/plugins/kirby3-htmlpurifier` or\n- `composer require bnomei/kirby3-htmlpurifier`\n\n## Usage PHP\n\n```php\n$cleanHtml = \\Bnomei\\HtmlPurifier::purify($dirtyHtml);\n```\n\n## Usage Uniform-Guard\n\nBecause of the plugin loading order the `htmlPurifyGuard` will only be available with composer installations of this plugin.\n\n```php\n$form = new \\Uniform\\Form;\n\nif (kirby()-\u003erequest()-\u003eis('POST')) {\n\n    $form-\u003ehoneypotGuard() // needs to be called explicitly now\n        -\u003ehtmlPurifyGuard(); // purified all data\n\n    if ($form-\u003esuccess()) {\n        // ...\n    }\n}\n```\n\n## Usage Field-Method\n\n```php\n$dirtHtml = (string) $page-\u003emyfield();\n$cleanHtml = (string) $page-\u003emyfield()-\u003ehtmlPurify();\n$cleanHtml = (string) $page-\u003emyfield()-\u003ekirbytext()-\u003ehtmlPurify();\n```\n\n## Usage with KQL for headless\n\nIf you want to make extra sure your html output to headless is valid html you can purify your fields. Be advised that this will come with a performance penalty since purification is no simple task.\n\n\u003e ⚠️ All proprietary elements (`\u003ctemplate\u003e`, ...) and attributes (`srcset`, `sizes`, `data-*`, `x-*:`, `@*:`, ...) will be removed! \n\n**KQL Query**\n```json\n{\n    \"query\": \"page('photography')\",\n    \"select\": {\n        \"url\": true,\n        \"title\": true,\n        \"textWithPurifiedHtml\": \"page.text.kirbytext.htmlPurify\"\n    }\n}\n```\n\n**Example: Vue**\n```vue\n\u003cdiv v-html=\"textWithPurifiedHtml\"\u003e\u003c/div\u003e\n```\n\n## Settings\n\n| bnomei.htmlpurifier.            | Default        | Description               |            \n|---------------------------|----------------|---------------------------|\n| config | callback | overwrite this to adjust the config of used HtmlPurifier dependency |\n\n## Dependecies\n\n- [Kirby 3 Plugin Uniform](https://github.com/mzur/kirby-uniform)\n- [HtmlPurifier](https://github.com/ezyang/htmlpurifier)\n\n## Disclaimer\n\nThis plugin is provided \"as is\" with no guarantee. Use it at your own risk and always test it yourself before using it in a production environment. If you find any issues, please [create a new issue](https://github.com/bnomei/kirby3-htmlpurifier/issues/new).\n\n## License\n\n[MIT](https://opensource.org/licenses/MIT)\n\nIt is discouraged to use this plugin in any project that promotes racism, sexism, homophobia, animal abuse, violence or any other form of hate speech.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbnomei%2Fkirby3-htmlpurifier","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbnomei%2Fkirby3-htmlpurifier","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbnomei%2Fkirby3-htmlpurifier/lists"}