From f45a286b8d62f710b519a98c7d4b75a0c34d5d10 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 22 Jun 2009 13:56:49 +0400 Subject: strip_tags_long: use htmlpurifier to properly reformat html content --- .../library/HTMLPurifier/URIScheme/ftp.php | 43 ++++++++++++++++++++++ .../library/HTMLPurifier/URIScheme/http.php | 20 ++++++++++ .../library/HTMLPurifier/URIScheme/https.php | 12 ++++++ .../library/HTMLPurifier/URIScheme/mailto.php | 27 ++++++++++++++ .../library/HTMLPurifier/URIScheme/news.php | 22 +++++++++++ .../library/HTMLPurifier/URIScheme/nntp.php | 20 ++++++++++ 6 files changed, 144 insertions(+) create mode 100755 lib/htmlpurifier/library/HTMLPurifier/URIScheme/ftp.php create mode 100755 lib/htmlpurifier/library/HTMLPurifier/URIScheme/http.php create mode 100755 lib/htmlpurifier/library/HTMLPurifier/URIScheme/https.php create mode 100755 lib/htmlpurifier/library/HTMLPurifier/URIScheme/mailto.php create mode 100755 lib/htmlpurifier/library/HTMLPurifier/URIScheme/news.php create mode 100755 lib/htmlpurifier/library/HTMLPurifier/URIScheme/nntp.php (limited to 'lib/htmlpurifier/library/HTMLPurifier/URIScheme') diff --git a/lib/htmlpurifier/library/HTMLPurifier/URIScheme/ftp.php b/lib/htmlpurifier/library/HTMLPurifier/URIScheme/ftp.php new file mode 100755 index 000000000..5849bf7ff --- /dev/null +++ b/lib/htmlpurifier/library/HTMLPurifier/URIScheme/ftp.php @@ -0,0 +1,43 @@ +query = null; + + // typecode check + $semicolon_pos = strrpos($uri->path, ';'); // reverse + if ($semicolon_pos !== false) { + $type = substr($uri->path, $semicolon_pos + 1); // no semicolon + $uri->path = substr($uri->path, 0, $semicolon_pos); + $type_ret = ''; + if (strpos($type, '=') !== false) { + // figure out whether or not the declaration is correct + list($key, $typecode) = explode('=', $type, 2); + if ($key !== 'type') { + // invalid key, tack it back on encoded + $uri->path .= '%3B' . $type; + } elseif ($typecode === 'a' || $typecode === 'i' || $typecode === 'd') { + $type_ret = ";type=$typecode"; + } + } else { + $uri->path .= '%3B' . $type; + } + $uri->path = str_replace(';', '%3B', $uri->path); + $uri->path .= $type_ret; + } + + return true; + } + +} + +// vim: et sw=4 sts=4 diff --git a/lib/htmlpurifier/library/HTMLPurifier/URIScheme/http.php b/lib/htmlpurifier/library/HTMLPurifier/URIScheme/http.php new file mode 100755 index 000000000..b097a31d6 --- /dev/null +++ b/lib/htmlpurifier/library/HTMLPurifier/URIScheme/http.php @@ -0,0 +1,20 @@ +userinfo = null; + return true; + } + +} + +// vim: et sw=4 sts=4 diff --git a/lib/htmlpurifier/library/HTMLPurifier/URIScheme/https.php b/lib/htmlpurifier/library/HTMLPurifier/URIScheme/https.php new file mode 100755 index 000000000..29e380919 --- /dev/null +++ b/lib/htmlpurifier/library/HTMLPurifier/URIScheme/https.php @@ -0,0 +1,12 @@ +userinfo = null; + $uri->host = null; + $uri->port = null; + // we need to validate path against RFC 2368's addr-spec + return true; + } + +} + +// vim: et sw=4 sts=4 diff --git a/lib/htmlpurifier/library/HTMLPurifier/URIScheme/news.php b/lib/htmlpurifier/library/HTMLPurifier/URIScheme/news.php new file mode 100755 index 000000000..f5f54f4f5 --- /dev/null +++ b/lib/htmlpurifier/library/HTMLPurifier/URIScheme/news.php @@ -0,0 +1,22 @@ +userinfo = null; + $uri->host = null; + $uri->port = null; + $uri->query = null; + // typecode check needed on path + return true; + } + +} + +// vim: et sw=4 sts=4 diff --git a/lib/htmlpurifier/library/HTMLPurifier/URIScheme/nntp.php b/lib/htmlpurifier/library/HTMLPurifier/URIScheme/nntp.php new file mode 100755 index 000000000..5bf93ea78 --- /dev/null +++ b/lib/htmlpurifier/library/HTMLPurifier/URIScheme/nntp.php @@ -0,0 +1,20 @@ +userinfo = null; + $uri->query = null; + return true; + } + +} + +// vim: et sw=4 sts=4 -- cgit v1.2.3