Skip to content

Commit

Permalink
patch HtmLawedVanillaWrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
mvorisek committed Dec 12, 2023
1 parent af15e53 commit 18c3d78
Showing 1 changed file with 21 additions and 12 deletions.
33 changes: 21 additions & 12 deletions HtmLawed/HtmLawedVanillaWrapper.php
Original file line number Diff line number Diff line change
@@ -1,18 +1,30 @@
<?php

// Downloaded from https://github.com/vanilla/htmlawed/blob/v2.2.15/src/Htmlawed.php
// with the following modifications:
// 1. add `DataTables\HtmLawed` namespace
// 2. rename class name from `Htmlawed` to `HtmLawedVanillaWrapper`
// 3. readd PHP 5.3 support - change `[]` array constructor syntax to `array()`
// 4. remove https://github.com/vanilla/htmlawed/blob/v2.2.15/src/Htmlawed.php#L45 line
// 5. update `htmLawed` call on https://github.com/vanilla/htmlawed/blob/v2.2.15/src/Htmlawed.php#L59 line to `HtmLawed::hl`
// 6. add missing `string` type to phpdoc on https://github.com/vanilla/htmlawed/blob/v2.2.15/src/Htmlawed.php#L66 line

/**
* @author Todd Burry <[email protected]>
* @copyright 2009-2014 Vanilla Forums Inc.
* @license LGPL-3.0
*/

namespace DataTables\HtmLawed;

/**
* A class wrapper for the htmLawed library.
*/
class Htmlawed {
class HtmLawedVanillaWrapper {
/// Methods ///

public static $defaultConfig = [
'anti_link_spam' => ['`.`', ''],
public static $defaultConfig = array(
'anti_link_spam' => array('`.`', ''),
'balance' => 1,
'cdata' => 3,
'safe' => 1,
Expand All @@ -25,12 +37,12 @@ class Htmlawed {
'schemes' => 'classid:clsid; href: aim, feed, file, ftp, gopher, http, https, irc, mailto, news, nntp, sftp, ssh, telnet; style: nil; *:file, http, https', // clsid allowed in class
'unique_ids' => 0,
'valid_xhtml' => 0,
];
);

public static $defaultSpec = [
public static $defaultSpec = array(
'object=-classid-type, -codebase',
'embed=type(oneof=application/x-shockwave-flash)'
];
);

/**
* Filters a string of html with the htmLawed library.
Expand All @@ -42,8 +54,6 @@ class Htmlawed {
* @see http://www.bioinformatics.org/phplabware/internal_utilities/htmLawed/htmLawed_README.htm
*/
public static function filter($html, array $config = null, $spec = null) {
require_once __DIR__.'/htmLawed/htmLawed.php';

if ($config === null) {
$config = self::$defaultConfig;
}
Expand All @@ -56,20 +66,20 @@ public static function filter($html, array $config = null, $spec = null) {
$spec = static::$defaultSpec;
}

return htmLawed($html, $config, $spec);
return HtmLawed::hl($html, $config, $spec);
}


/**
* Filter a string of html so that it can be put into an rss feed.
*
* @param $html The html text to fitlter.
* @param string $html The html text to fitlter.
* @return string Returns the filtered html.
* @see Htmlawed::filter().
*/
public static function filterRSS($html) {
$config = array(
'anti_link_spam' => ['`.`', ''],
'anti_link_spam' => array('`.`', ''),
'comment' => 1,
'cdata' => 3,
'css_expression' => 1,
Expand All @@ -87,4 +97,3 @@ public static function filterRSS($html) {
return $result;
}
}

0 comments on commit 18c3d78

Please sign in to comment.