X-Git-Url: https://git.ao2.it/tweeper.git/blobdiff_plain/69e71256e0c4a30c57fe13f0ff5b3038e2c5f563..7097a8ad2ef040bc81a8c5f7ed7cc02e0073eaab:/tweeper.php?ds=sidebyside diff --git a/tweeper.php b/tweeper.php index 178176d..efc0fd6 100644 --- a/tweeper.php +++ b/tweeper.php @@ -244,7 +244,10 @@ class Tweeper { return NULL; } - $xsltProcessor = $this->load_stylesheet($url["host"]); + // Strip the leading www. to be more forgiving on input URLs + $host = preg_replace('/^www\./', '', $url["host"]); + + $xsltProcessor = $this->load_stylesheet($host); if (NULL === $xsltProcessor) { return NULL; } @@ -254,7 +257,12 @@ class Tweeper { return NULL; } - $xmlDoc = $this->html_to_xml($html, $url["host"]); + $preprocess_html_host_method = 'preprocess_html_' . str_replace(".", "_", $host); + if (method_exists($this, $preprocess_html_host_method)) { + $html = call_user_func_array(array($this, $preprocess_html_host_method), array($html)); + } + + $xmlDoc = $this->html_to_xml($html, $host); if (NULL === $xmlDoc) { return NULL; }