Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 86ca784

Browse files
author
Edward Z. Yang
committed
Convert all to new configuration get/set format.
Signed-off-by: Edward Z. Yang <[email protected]>
1 parent b107eec commit 86ca784

106 files changed

Lines changed: 504 additions & 815 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

configdoc/usage.xml

Lines changed: 1 addition & 401 deletions
Large diffs are not rendered by default.

docs/dev-config-bcbreaks.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ look something like %Filter.YouTube.Blacklist. While you could technically
3333
set it with ('HTML', 'YouTube.Blacklist'), the logical extension
3434
('HTML', 'YouTube', 'Blacklist') does not work.
3535

36-
[more changes coming]
36+
The old API will still work, but will emit E_USER_NOTICEs.
3737

3838

3939

docs/examples/basic.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
$config = HTMLPurifier_Config::createDefault();
99

1010
// configuration goes here:
11-
$config->set('Core', 'Encoding', 'UTF-8'); // replace with your encoding
12-
$config->set('HTML', 'Doctype', 'XHTML 1.0 Transitional'); // replace with your doctype
11+
$config->set('Core.Encoding', 'UTF-8'); // replace with your encoding
12+
$config->set('HTML.Doctype', 'XHTML 1.0 Transitional'); // replace with your doctype
1313

1414
$purifier = new HTMLPurifier($config);
1515

library/HTMLPurifier.kses.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ function kses($string, $allowed_html, $allowed_protocols = null) {
1717
$allowed_attributes["$element.$attribute"] = true;
1818
}
1919
}
20-
$config->set('HTML', 'AllowedElements', $allowed_elements);
21-
$config->set('HTML', 'AllowedAttributes', $allowed_attributes);
20+
$config->set('HTML.AllowedElements', $allowed_elements);
21+
$config->set('HTML.AllowedAttributes', $allowed_attributes);
2222
$allowed_schemes = array();
2323
if ($allowed_protocols !== null) {
24-
$config->set('URI', 'AllowedSchemes', $allowed_protocols);
24+
$config->set('URI.AllowedSchemes', $allowed_protocols);
2525
}
2626
$purifier = new HTMLPurifier($config);
2727
return $purifier->purify($string);

library/HTMLPurifier.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ public function purify($html, $config = null) {
128128
$context->register('Generator', $this->generator);
129129

130130
// set up global context variables
131-
if ($config->get('Core', 'CollectErrors')) {
131+
if ($config->get('Core.CollectErrors')) {
132132
// may get moved out if other facilities use it
133133
$language_factory = HTMLPurifier_LanguageFactory::instance();
134134
$language = $language_factory->create($config, $context);

library/HTMLPurifier/AttrDef/CSS/Color.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class HTMLPurifier_AttrDef_CSS_Color extends HTMLPurifier_AttrDef
99
public function validate($color, $config, $context) {
1010

1111
static $colors = null;
12-
if ($colors === null) $colors = $config->get('Core', 'ColorKeywords');
12+
if ($colors === null) $colors = $config->get('Core.ColorKeywords');
1313

1414
$color = trim($color);
1515
if ($color === '') return false;

library/HTMLPurifier/AttrDef/HTML/Color.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class HTMLPurifier_AttrDef_HTML_Color extends HTMLPurifier_AttrDef
99
public function validate($string, $config, $context) {
1010

1111
static $colors = null;
12-
if ($colors === null) $colors = $config->get('Core', 'ColorKeywords');
12+
if ($colors === null) $colors = $config->get('Core.ColorKeywords');
1313

1414
$string = trim($string);
1515

library/HTMLPurifier/AttrDef/HTML/FrameTarget.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class HTMLPurifier_AttrDef_HTML_FrameTarget extends HTMLPurifier_AttrDef_Enum
1212
public function __construct() {}
1313

1414
public function validate($string, $config, $context) {
15-
if ($this->valid_values === false) $this->valid_values = $config->get('Attr', 'AllowedFrameTargets');
15+
if ($this->valid_values === false) $this->valid_values = $config->get('Attr.AllowedFrameTargets');
1616
return parent::validate($string, $config, $context);
1717
}
1818

library/HTMLPurifier/AttrDef/HTML/ID.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,18 @@ class HTMLPurifier_AttrDef_HTML_ID extends HTMLPurifier_AttrDef
1717

1818
public function validate($id, $config, $context) {
1919

20-
if (!$config->get('Attr', 'EnableID')) return false;
20+
if (!$config->get('Attr.EnableID')) return false;
2121

2222
$id = trim($id); // trim it first
2323

2424
if ($id === '') return false;
2525

26-
$prefix = $config->get('Attr', 'IDPrefix');
26+
$prefix = $config->get('Attr.IDPrefix');
2727
if ($prefix !== '') {
28-
$prefix .= $config->get('Attr', 'IDPrefixLocal');
28+
$prefix .= $config->get('Attr.IDPrefixLocal');
2929
// prevent re-appending the prefix
3030
if (strpos($id, $prefix) !== 0) $id = $prefix . $id;
31-
} elseif ($config->get('Attr', 'IDPrefixLocal') !== '') {
31+
} elseif ($config->get('Attr.IDPrefixLocal') !== '') {
3232
trigger_error('%Attr.IDPrefixLocal cannot be used unless '.
3333
'%Attr.IDPrefix is set', E_USER_WARNING);
3434
}
@@ -51,7 +51,7 @@ public function validate($id, $config, $context) {
5151
$result = ($trim === '');
5252
}
5353

54-
$regexp = $config->get('Attr', 'IDBlacklistRegexp');
54+
$regexp = $config->get('Attr.IDBlacklistRegexp');
5555
if ($regexp && preg_match($regexp, $id)) {
5656
return false;
5757
}

library/HTMLPurifier/AttrDef/HTML/LinkTypes.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function __construct($name) {
2727

2828
public function validate($string, $config, $context) {
2929

30-
$allowed = $config->get('Attr', $this->name);
30+
$allowed = $config->get('Attr.' . $this->name);
3131
if (empty($allowed)) return false;
3232

3333
$string = $this->parseCDATA($string);

0 commit comments

Comments
 (0)