From d443ffcf03ac044dcd70e4d999660bd60f8679ab Mon Sep 17 00:00:00 2001 From: William Allen Date: Tue, 13 Oct 2026 10:54:19 -0400 Subject: [PATCH] Remove XSLT --- Dockerfile | 2 - app/Http/Controllers/AbstractController.php | 3 +- app/cdash/include/common.php | 141 -------------------- composer.json | 1 - composer.lock | 3 +- docs/install.md | 1 - phpstan-baseline.neon | 90 ------------- resources/views/cdash.blade.php | 4 +- 8 files changed, 4 insertions(+), 241 deletions(-) diff --git a/Dockerfile b/Dockerfile index db4a741f64..8cc5dce461 100644 --- a/Dockerfile +++ b/Dockerfile @@ -36,7 +36,6 @@ RUN apt-get update && \ libldap2-dev \ libpng-dev \ libpq-dev \ - libxslt-dev \ libxss1 \ nodejs \ unzip \ @@ -52,7 +51,6 @@ RUN apt-get update && \ gd \ ldap \ pdo_pgsql \ - xsl \ opcache \ && \ curl -fsSL https://composer.github.io/installer.sha384sum > checksum && \ diff --git a/app/Http/Controllers/AbstractController.php b/app/Http/Controllers/AbstractController.php index 0a52c4be50..0225157177 100755 --- a/app/Http/Controllers/AbstractController.php +++ b/app/Http/Controllers/AbstractController.php @@ -40,8 +40,7 @@ protected function angular_view(string $view, string $title = ''): View $controller_name = Str::studly($file) . 'Controller'; return $this->view('cdash', $title) - ->with('xsl_content', file_get_contents(resource_path("js/angular/views/$view.html"))) - ->with('xsl', true) + ->with('angular_content', file_get_contents(resource_path("js/angular/views/$view.html"))) ->with('angular', true) ->with('angular_controller', $controller_name); } diff --git a/app/cdash/include/common.php b/app/cdash/include/common.php index 670d651021..6e85655f04 100644 --- a/app/cdash/include/common.php +++ b/app/cdash/include/common.php @@ -120,97 +120,6 @@ function get_param($name, $required = true): string return pdo_real_escape_string($value); } -function xslt_process(XSLTProcessor $xsltproc, - $xml_arg, - $xsl_arg, - $xslcontainer = null, - $args = null, - $params = null) -{ - // Start with preparing the arguments - $xml_arg = str_replace('arg:', '', $xml_arg); - $xsl_arg = str_replace('arg:', '', $xsl_arg); - - // Create instances of the DomDocument class - $xml = new DOMDocument(); - $xsl = new DOMDocument(); - - // Load the xml document and the xsl template - if (LIBXML_VERSION >= 20700) { - $xmlOptions = LIBXML_PARSEHUGE; - } else { - $xmlOptions = 0; - } - - $xml->loadXML($args[$xml_arg], $xmlOptions); - $xsl->loadXML(file_get_contents($xsl_arg), $xmlOptions); - - // Load the xsl template - $xsltproc->importStylesheet($xsl); - - // Set parameters when defined - if ($params) { - foreach ($params as $param => $value) { - $xsltproc->setParameter('', $param, $value); - } - } - - // Start the transformation - $processed = $xsltproc->transformToXml($xml); - - // Put the result in a file when specified - if ($xslcontainer) { - return @file_put_contents($xslcontainer, $processed); - } - - return $processed; -} - -/** - * Do the XSLT translation - */ -function generate_XSLT($xml, string $pageName, bool $return_html = false): string -{ - $xh = new XSLTProcessor(); - - $arguments = [ - '/_xml' => $xml, - ]; - - $xslpage = $pageName . '.xsl'; - - $html = xslt_process($xh, 'arg:/_xml', $xslpage, null, $arguments); - - unset($xh); - if ($return_html) { - return $html; - } - echo $html; - return ''; -} - -/** - * used to escape special XML characters - */ -function XMLStrFormat(string $str): string -{ - if (mb_detect_encoding($str, 'UTF-8', true) === false) { - $str = mb_convert_encoding($str, 'UTF-8'); - } - $str = str_replace('&', '&', $str); - $str = str_replace('<', '<', $str); - $str = str_replace('>', '>', $str); - $str = str_replace("'", ''', $str); - $str = str_replace('"', '"', $str); - $str = str_replace("\r", '', $str); - - // Remove UTF-8 characters that are not valid in an XML document. - // https://www.w3.org/TR/REC-xml/#charsets - $str = preg_replace('/[^\x{0009}\x{000a}\x{000d}\x{0020}-\x{D7FF}\x{E000}-\x{FFFD}]+/u', '', $str); - - return $str; -} - function time_difference($duration, bool $compact = false, string $suffix = '', bool $displayms = false): string { $duration = is_numeric($duration) ? $duration : 0; @@ -365,21 +274,6 @@ function get_seconds_from_interval($input) return null; } -function xml_replace_callback($matches): string -{ - $decimal_value = hexdec(bin2hex($matches[0])); - return '&#' . $decimal_value . ';'; -} - -/** - * Add an XML tag to a string - */ -function add_XML_value(string $tag, $value): string -{ - $value = preg_replace_callback('/[\x1b]/', 'xml_replace_callback', $value); - return '<' . $tag . '>' . XMLStrFormat($value) . ''; -} - /** * Get the project id from the project name */ @@ -537,11 +431,6 @@ function get_css_file(): string return $classic; } -function begin_XML_for_XSLT(): string -{ - return ''; -} - function begin_JSON_response(): array { $response = []; @@ -855,36 +744,6 @@ function extract_tar(string $stored_filepath): string throw new RuntimeException('Unable to determine valid extraction directory'); } -/** - * Encode structures for safe HTML output - */ -function deepEncodeHTMLEntities(&$structure): void -{ - $encode = fn ($string) => htmlspecialchars($string, ENT_QUOTES, 'UTF-8', false); - - if (is_object($structure)) { - $properties = get_object_vars($structure); - foreach ($properties as $key => &$prop) { - if (is_object($prop) || is_array($prop)) { - deepEncodeHTMLEntities($prop); - $structure->{$key} = $prop; - continue; - } - $structure->{$key} = $encode($prop); - } - } elseif (is_array($structure)) { - foreach ($structure as $key => &$value) { - if (is_object($value) || is_array($value)) { - deepEncodeHTMLEntities($value); - continue; - } - $value = $encode($value); - } - } elseif (is_string($structure)) { - $structure = $encode($structure); - } -} - /** * A light wrapper around PDOStatement::fetch. * diff --git a/composer.json b/composer.json index 9eedf0e1e6..06794d9fbb 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,6 @@ "ext-posix": "*", "ext-simplexml": "*", "ext-xml": "*", - "ext-xsl": "*", "ext-zlib": "*", "directorytree/ldaprecord-laravel": "3.4.3", "guzzlehttp/guzzle": "7.15.2", diff --git a/composer.lock b/composer.lock index d8c3ef244b..fcaeaa79ef 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "2fb3d8b75e96241304043c7d85681982", + "content-hash": "bc11ddbb88615712307b1de74c0a9b8f", "packages": [ { "name": "aws/aws-crt-php", @@ -12529,7 +12529,6 @@ "ext-posix": "*", "ext-simplexml": "*", "ext-xml": "*", - "ext-xsl": "*", "ext-zlib": "*" }, "platform-dev": { diff --git a/docs/install.md b/docs/install.md index e10e8ed485..6f66802dae 100644 --- a/docs/install.md +++ b/docs/install.md @@ -24,7 +24,6 @@ CDash needs the following PHP modules installed and enabled. - ldap - mbstring - pdo_pgsql -- xsl - posix - simplexml - tokenizer diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 2836502c64..e4c738c88c 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -11361,18 +11361,6 @@ parameters: count: 1 path: app/cdash/include/common.php - - - rawMessage: 'Function XMLStrFormat() should return string but returns string|null.' - identifier: return.type - count: 1 - path: app/cdash/include/common.php - - - - rawMessage: 'Function add_XML_value() has parameter $value with no type specified.' - identifier: missingType.parameter - count: 1 - path: app/cdash/include/common.php - - rawMessage: 'Function begin_JSON_response() return type has no value type specified in iterable type array.' identifier: missingType.iterableValue @@ -11457,18 +11445,6 @@ parameters: count: 2 path: app/cdash/include/common.php - - - rawMessage: 'Function deepEncodeHTMLEntities() has parameter $structure with no type specified.' - identifier: missingType.parameter - count: 1 - path: app/cdash/include/common.php - - - - rawMessage: 'Function generate_XSLT() has parameter $xml with no type specified.' - identifier: missingType.parameter - count: 1 - path: app/cdash/include/common.php - - rawMessage: 'Function get_dashboard_JSON() has parameter $date with no type specified.' identifier: missingType.parameter @@ -11613,48 +11589,6 @@ parameters: count: 1 path: app/cdash/include/common.php - - - rawMessage: 'Function xml_replace_callback() has parameter $matches with no type specified.' - identifier: missingType.parameter - count: 1 - path: app/cdash/include/common.php - - - - rawMessage: 'Function xslt_process() has no return type specified.' - identifier: missingType.return - count: 1 - path: app/cdash/include/common.php - - - - rawMessage: 'Function xslt_process() has parameter $args with no type specified.' - identifier: missingType.parameter - count: 1 - path: app/cdash/include/common.php - - - - rawMessage: 'Function xslt_process() has parameter $params with no type specified.' - identifier: missingType.parameter - count: 1 - path: app/cdash/include/common.php - - - - rawMessage: 'Function xslt_process() has parameter $xml_arg with no type specified.' - identifier: missingType.parameter - count: 1 - path: app/cdash/include/common.php - - - - rawMessage: 'Function xslt_process() has parameter $xsl_arg with no type specified.' - identifier: missingType.parameter - count: 1 - path: app/cdash/include/common.php - - - - rawMessage: 'Function xslt_process() has parameter $xslcontainer with no type specified.' - identifier: missingType.parameter - count: 1 - path: app/cdash/include/common.php - - rawMessage: 'Loose comparison via "!=" between mixed and string is not allowed.' identifier: notEqual.notAllowed @@ -11727,12 +11661,6 @@ parameters: count: 1 path: app/cdash/include/common.php - - - rawMessage: 'Parameter #1 $filename of function file_get_contents expects string, (array|string) given.' - identifier: argument.type - count: 1 - path: app/cdash/include/common.php - - rawMessage: 'Parameter #1 $num of function is_infinite expects float, float|int|string given.' identifier: argument.type @@ -11745,18 +11673,6 @@ parameters: count: 1 path: app/cdash/include/common.php - - - rawMessage: 'Parameter #1 $source of method DOMDocument::loadXML() expects non-empty-string, string|false given.' - identifier: argument.type - count: 1 - path: app/cdash/include/common.php - - - - rawMessage: 'Parameter #1 $str of function XMLStrFormat expects string, (array|string|null) given.' - identifier: argument.type - count: 1 - path: app/cdash/include/common.php - - rawMessage: 'Parameter #1 $string of function strlen expects string, (string|false) given.' identifier: argument.type @@ -11817,12 +11733,6 @@ parameters: count: 1 path: app/cdash/include/common.php - - - rawMessage: Variable property access on object. - identifier: property.dynamicName - count: 2 - path: app/cdash/include/common.php - - rawMessage: Access to an undefined property DefaultFilters::$TextConcat. identifier: property.notFound diff --git a/resources/views/cdash.blade.php b/resources/views/cdash.blade.php index 56f80fe26d..5e041f2cb5 100755 --- a/resources/views/cdash.blade.php +++ b/resources/views/cdash.blade.php @@ -86,8 +86,8 @@ @hasSection('main_content') @yield('main_content') - @elseif(isset($xsl) && $xsl === true) - {!! $xsl_content !!} + @elseif(isset($angular) && $angular === true) + {!! $angular_content !!} @endif