Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ RUN apt-get update && \
libldap2-dev \
libpng-dev \
libpq-dev \
libxslt-dev \
libxss1 \
nodejs \
unzip \
Expand All @@ -52,7 +51,6 @@ RUN apt-get update && \
gd \
ldap \
pdo_pgsql \
xsl \
opcache \
&& \
curl -fsSL https://composer.github.io/installer.sha384sum > checksum && \
Expand Down
3 changes: 1 addition & 2 deletions app/Http/Controllers/AbstractController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
141 changes: 0 additions & 141 deletions app/cdash/include/common.php
Original file line number Diff line number Diff line change
Expand Up @@ -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('<', '&lt;', $str);
$str = str_replace('>', '&gt;', $str);
$str = str_replace("'", '&apos;', $str);
$str = str_replace('"', '&quot;', $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;
Expand Down Expand Up @@ -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) . '</' . $tag . '>';
}

/**
* Get the project id from the project name
*/
Expand Down Expand Up @@ -537,11 +431,6 @@ function get_css_file(): string
return $classic;
}

function begin_XML_for_XSLT(): string
{
return '<?xml version="1.0" encoding="UTF-8"?><cdash>';
}

function begin_JSON_response(): array
{
$response = [];
Expand Down Expand Up @@ -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.
*
Expand Down
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
3 changes: 1 addition & 2 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion docs/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ CDash needs the following PHP modules installed and enabled.
- ldap
- mbstring
- pdo_pgsql
- xsl
- posix
- simplexml
- tokenizer
Expand Down
90 changes: 0 additions & 90 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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>|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
Expand All @@ -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>|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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions resources/views/cdash.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
</div>

Expand Down
Loading