Skip to content

Commit

Permalink
New tool for detecting broken XML files
Browse files Browse the repository at this point in the history
  • Loading branch information
André L F S Bacci committed Jan 15, 2025
1 parent 4c06c90 commit 42d1188
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 275 deletions.
31 changes: 4 additions & 27 deletions scripts/translation/qaxml.php → scripts/broken.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
# Description
This command line utility test if an file is valid standalone XML file,
ignoring undefined entities. If an directory is informed, the test is
applied in all .xml files in directory and sub directories.
accepting undefined entities references. If an directory is informed,
the test is applied in all .xml files in directory and sub directories.
This tool also cares for directories marked with .xmlfragmentdir, so
theses files are tested in relaxed semantics for XML fragments. */
Expand Down Expand Up @@ -122,7 +122,7 @@ function testFile( string $filename , bool $fragment = false )

function testDir( string $dir )
{
$dir = realpain( $dir );
$dir = realpath( $dir );
$files = scandir( $dir );
$fragment = false;
$subdirs = [];
Expand All @@ -137,7 +137,7 @@ function testDir( string $dir )
if ( $file[0] == "." )
continue;

$fullpath = realpain( "$dir/$file" );
$fullpath = realpath( "$dir/$file" );

if ( is_dir ( $fullpath ) )
{
Expand All @@ -152,26 +152,3 @@ function testDir( string $dir )
foreach( $subdirs as $dir )
testDir( $dir );
}

function realpain( string $path , bool $touch = false , bool $mkdir = false ) : string
{
// pain is real

// care for external XML tools (realpath() everywhere)
// care for Windows builds (foward slashes everywhere)
// avoid `cd` and chdir() like the plague

$path = str_replace( "\\" , '/' , $path );

if ( $mkdir && ! file_exists( $path ) )
mkdir( $path , recursive: true );

if ( $touch && ! file_exists( $path ) )
touch( $path );

$res = realpath( $path );
if ( is_string( $res ) )
$path = $res;

return $path;
}
141 changes: 0 additions & 141 deletions scripts/translation/libqa/OutputBuffer.php

This file was deleted.

107 changes: 0 additions & 107 deletions scripts/translation/libqa/OutputIgnore.php

This file was deleted.

0 comments on commit 42d1188

Please sign in to comment.