Skip to content
Browse files

MDL-32427 fix suport for extra schemes in links in HTML Purifier

  • Loading branch information...
1 parent 93fb7b5 commit c609c3968e0edcc650380a84068e5c41271ac929 @skodak skodak committed Apr 23, 2012
Showing with 108 additions and 1 deletion.
  1. +105 −0 lib/htmlpurifier/locallib.php
  2. +2 −1 lib/htmlpurifier/readme_moodle.txt
  3. +1 −0 lib/weblib.php
View
105 lib/htmlpurifier/locallib.php
@@ -0,0 +1,105 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Extra classes needed for HTMLPurifier customisation for Moodle.
+ *
+ * @package core
+ * @copyright 2012 Petr Skoda {@link http://skodak.org}
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL 3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die();
+
+
+/**
+ * Validates RTSP defined by RFC 2326
+ */
+class HTMLPurifier_URIScheme_rtsp extends HTMLPurifier_URIScheme {
+
+ public $browsable = true;
+ public $hierarchical = true;
+
+ public function doValidate(&$uri, $config, $context) {
+ $uri->userinfo = null;
+ return true;
+ }
+
+}
+
+
+/**
+ * Validates IRC defined by IETF Draft
+ */
+class HTMLPurifier_URIScheme_irc extends HTMLPurifier_URIScheme {
+
+ public $browsable = true;
+ public $hierarchical = true;
+
+ public function doValidate(&$uri, $config, $context) {
+ $uri->userinfo = null;
+ return true;
+ }
+
+}
+
+
+/**
+ * Validates MMS defined by Microsoft
+ */
+class HTMLPurifier_URIScheme_mms extends HTMLPurifier_URIScheme {
+
+ public $browsable = true;
+ public $hierarchical = true;
+
+ public function doValidate(&$uri, $config, $context) {
+ $uri->userinfo = null;
+ return true;
+ }
+
+}
+
+
+/**
+ * Validates Gopher defined by RFC 4266
+ */
+class HTMLPurifier_URIScheme_gopher extends HTMLPurifier_URIScheme {
+
+ public $browsable = true;
+ public $hierarchical = true;
+
+ public function doValidate(&$uri, $config, $context) {
+ $uri->userinfo = null;
+ return true;
+ }
+
+}
+
+
+/**
+ * Validates TeamSpeak defined by TeamSpeak
+ */
+class HTMLPurifier_URIScheme_teamspeak extends HTMLPurifier_URIScheme {
+
+ public $browsable = true;
+ public $hierarchical = true;
+
+ public function doValidate(&$uri, $config, $context) {
+ $uri->userinfo = null;
+ return true;
+ }
+
+}
View
3 lib/htmlpurifier/readme_moodle.txt
@@ -1,6 +1,7 @@
Description of HTML Purifier v4.4.0+ library import into Moodle
(Includes _blank fix 8c9d461a6259d7b8ac4ae5c9c9e95ab176cfcda3.)
-No Changes..
+Changes:
+* added locallib.php with Moodle specific extensions
skodak
View
1 lib/weblib.php
@@ -1474,6 +1474,7 @@ function purify_html($text, $options = array()) {
check_dir_exists($cachedir);
require_once $CFG->libdir.'/htmlpurifier/HTMLPurifier.safe-includes.php';
+ require_once $CFG->libdir.'/htmlpurifier/locallib.php';
$config = HTMLPurifier_Config::createDefault();
$config->set('HTML.DefinitionID', 'moodlehtml');

0 comments on commit c609c39

Please sign in to comment.
Something went wrong with that request. Please try again.