Skip to content

Commit 9ce2eef

Browse files
committed
Update to upstream 1.2.6
Signed-off-by: Kevin Decherf <kevin@kdecherf.com>
1 parent b89df7c commit 9ce2eef

2 files changed

Lines changed: 27 additions & 9 deletions

File tree

htmLawed.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22

33
/*
4-
htmLawed 1.2.4.2, 16 May 2019
4+
htmLawed 1.2.6, 4 September 2021
55
Copyright Santosh Patnaik
66
Dual licensed with LGPL 3 and GPL 2+
77
A PHP Labware internal utility - www.bioinformatics.org/phplabware/internal_utilities/htmLawed
@@ -46,8 +46,8 @@ function htmLawed($t, $C = 1, $S = [])
4646
}
4747
$C['elements'] = &$e;
4848
// config attrs
49-
$x = !empty($C['deny_attribute']) ? strtolower(str_replace(["\n", "\r", "\t", ' '], '', $C['deny_attribute'])) : '';
50-
$x = array_flip((isset($x[0]) && '*' === $x[0]) ? str_replace('/', 'data-', explode('-', str_replace('data-', '/', $x))) : explode(',', $x . (!empty($C['safe']) ? ',on*' : '')));
49+
$x = !empty($C['deny_attribute']) ? strtolower(preg_replace('"\s+-"', '/', trim($C['deny_attribute']))) : '';
50+
$x = array_flip((isset($x[0]) && '*' === $x[0]) ? explode('/', $x) : explode(',', $x . (!empty($C['safe']) ? ',on*' : '')));
5151
$C['deny_attribute'] = $x;
5252
// config URLs
5353
$x = (isset($C['schemes'][2]) && strpos($C['schemes'], ':')) ? strtolower($C['schemes']) : 'href: aim, feed, file, ftp, gopher, http, https, irc, mailto, news, nntp, sftp, ssh, tel, telnet' . (empty($C['safe']) ? ', app, javascript; *: data, javascript, ' : '; *:') . 'file, http, https';
@@ -1016,11 +1016,11 @@ function hl_tag2(&$e, &$a, $t = 1)
10161016
$a2 = '';
10171017
while (preg_match('`(^|\s)(color|size)\s*=\s*(\'|")?(.+?)(\\3|\s|$)`i', $a, $m)) {
10181018
$a = str_replace($m[0], ' ', $a);
1019-
$a2 .= 'color' === strtolower($m[2]) ? (' color: ' . str_replace('"', '\'', trim($m[4])) . ';') : (isset($fs[($m = trim($m[4]))]) ? ($a2 .= ' font-size: ' . str_replace('"', '\'', $fs[$m]) . ';') : '');
1019+
$a2 .= 'color' === strtolower($m[2]) ? (' color: ' . str_replace(['"', ';', ':'], '\'', trim($m[4])) . ';') : (isset($fs[($m = trim($m[4]))]) ? (' font-size: ' . $fs[$m] . ';') : '');
10201020
}
10211021
while (preg_match('`(^|\s)face\s*=\s*(\'|")?([^=]+?)\\2`i', $a, $m) || preg_match('`(^|\s)face\s*=(\s*)(\S+)`i', $a, $m)) {
10221022
$a = str_replace($m[0], ' ', $a);
1023-
$a2 .= ' font-family: ' . str_replace('"', '\'', trim($m[3])) . ';';
1023+
$a2 .= ' font-family: ' . str_replace(['"', ';', ':'], '\'', trim($m[3])) . ';';
10241024
}
10251025
$e = 'span';
10261026

@@ -1130,5 +1130,5 @@ function hl_aux2($m)
11301130
function hl_version()
11311131
{
11321132
// version
1133-
return '1.2.4.2';
1133+
return '1.2.6';
11341134
}

htmLawedTest.php

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22

33
/*
4-
htmLawedTest.php, 17 May 2017
4+
htmLawedTest.php, 21 December 2020
55
To test htmLawed
66
Copyright Santosh Patnaik
77
Dual licensed with LGPL 3 and GPL 2+
@@ -36,6 +36,24 @@
3636
}
3737

3838
// slashes
39+
if (!function_exists('get_magic_quotes_gpc')) {
40+
function get_magic_quotes_gpc()
41+
{
42+
return false;
43+
}
44+
}
45+
if (!function_exists('get_magic_quotes_runtime')) {
46+
function get_magic_quotes_runtime()
47+
{
48+
return false;
49+
}
50+
}
51+
if (!function_exists('set_magic_quotes_runtime')) {
52+
function set_magic_quotes_runtime($new_setting)
53+
{
54+
return true;
55+
}
56+
}
3957
if (get_magic_quotes_gpc()) {
4058
foreach ($_POST as $k => $v) {
4159
$_POST[$k] = stripslashes($v);
@@ -564,8 +582,8 @@ function sndValidn(id, type){
564582
foreach ($cfg as $k => $v) {
565583
echo '<li>', $k, ': ';
566584
if (!empty($v[0])) { // input radio
567-
$j = $v[3];
568-
for ($i = $j - 1; ++$i < $v[0] + $v[3]; ++$j) {
585+
$j = (int) ($v[3]);
586+
for ($i = $j - 1; ++$i < (int) ($v[0]) + (int) ($v[3]); ++$j) {
569587
echo '<input type="radio" name="h', $k, '" value="', $i, '"', (!isset($_POST['h' . $k]) ? ($v[1] === $i ? ' checked="checked"' : '') : ($_POST['h' . $k] === $i ? ' checked="checked"' : '')), (isset($v['d']) ? ' disabled="disabled"' : ''), ' />', $i, ' ';
570588
}
571589
if ('nil' === $v[1]) {

0 commit comments

Comments
 (0)