Permalink
Browse files

mostly stuff regarding bug 62539

  • Loading branch information...
1 parent 9273958 commit d5826a3d240aae2571a40010e16d7c7c076f5b9b @paul999 paul999 committed Dec 22, 2010
View
@@ -44,6 +44,7 @@
$mpv = new mpv(null, mpv::UNZIP_PREFERENCE, false);
$mpv->output_type = (mpv::OUTPUT_TEXT);
+mpv::$exec_php = mpv::EXEC_PHP;
$mpv->validate($argv[1]);
print $lang['VALIDATION_RESULTS'] . "\n\n" . $mpv;
View
@@ -123,6 +123,14 @@ class mpv
private $message;
/**
+ * Array of "unwanted files/directories", all strtolowered
+ *
+ * @access private
+ * @var array
+ */
+ public static $unwanted_files;
+
+ /**
* Output type; either OUTPUT_BBCODE or OUTPUT_HTML
*
* @access public
@@ -161,6 +169,15 @@ class mpv
* @var array
*/
public $package_files;
+
+
+ /**
+ * Array containing all directories in a MOD package
+ *
+ * @access public
+ * @var array
+ */
+ public static $package_directories = array();
/**
* Array containing all XSL files
@@ -316,6 +333,11 @@ public function __construct($dir = null, $unzip_type = self::UNZIP_PREFERENCE, $
unset($exec_check);
}
+ if (defined('UNWANTED') && UNWANTED)
+ {
+ self::$unwanted_files = explode('|', UNWANTED);
+ }
+
$this->unzip_type = $unzip_type;
$this->remove_zip = $remove_zip;
$this->exec_php = self::DONT_EXEC_PHP;
@@ -325,10 +347,11 @@ public function __construct($dir = null, $unzip_type = self::UNZIP_PREFERENCE, $
$this->errors = array();
$this->message = '';
- $this->xsl_files = array();
- $this->modx_files = array();
- $this->package_files = array();
- $this->test_collections = array();
+ $this->xsl_files = array();
+ $this->modx_files = array();
+ $this->package_files = array();
+ $this->package_directories = array();
+ $this->test_collections = array();
$this->output_type = self::OUTPUT_BBCODE;
@@ -355,6 +378,20 @@ public function __construct($dir = null, $unzip_type = self::UNZIP_PREFERENCE, $
}
/**
+ * Check if the file is unwanted or not.
+ *
+ * @param string $directory
+ * @return boolean
+ */
+ public static function check_unwanted($directory)
+ {
+ $regexp = '#(^|.*/)(' . implode('|', array_map('preg_quote', self::$unwanted_files)) . ')(?:/|$)#i';
+
+ return preg_match($regexp, $directory) ? true : false;
+ }
+
+
+ /**
* error handler
*
* @param int $error_no
@@ -740,6 +777,8 @@ public static function dir_files($root, $dir = '')
{
$dir .= '/';
}
+
+ self::$package_directories[] = $dir;
if ($dh = opendir($root . $dir))
{
@@ -97,6 +97,11 @@ public function run()
foreach ($this->validator->package_files as $package_file)
{
$this->file_name = $package_file;
+
+ if (mpv::check_unwanted($package_file))
+ {
+ continue;
+ }
// Only test PHP files
// We also check files that should be binary, but arent.
@@ -110,6 +110,11 @@ public function run()
foreach ($this->validator->package_files as $package_file)
{
+ if (mpv::check_unwanted($package_file))
+ {
+ continue;
+ }
+
$this->file_name = $package_file;
// Only test PHP files
@@ -103,6 +103,11 @@ public function run()
foreach ($files as $package_file)
{
+ if (mpv::check_unwanted($package_file))
+ {
+ continue;
+ }
+
// Only test html, php, xml files
if (!in_array(strrchr($package_file, '.'), array('.php', '.xml', '.html')))
{
@@ -316,4 +321,4 @@ public function return_failed_tests()
{
return $this->failed_tests;
}
-}
+}
@@ -109,6 +109,11 @@ public function run()
{
continue;
}*/
+
+ if (mpv::check_unwanted($package_file))
+ {
+ continue;
+ }
$this->failed_tests = array();
@@ -99,6 +99,11 @@ public function run()
foreach ($this->validator->modx_files as $modx_filename => $modx_object)
{
$this->modx_filename = $modx_filename;
+
+ if (mpv::check_unwanted($modx_filename))
+ {
+ continue;
+ }
if (preg_match('#modx-(.*?)\.xsd#s', (string) $modx_object, $matches))
{
@@ -41,15 +41,6 @@ class mpv_tests_packaging
* @var array
*/
private $failed_tests;
-
- /**
- * Array of "unwanted files", all strtolowered
- *
- * @access private
- * @var array
- */
- private $unwanted_files = array('__macosx', '.ds_store', 'thumbs.db', '.svn');
-
/**
* String with valid MD5 for license.txt
@@ -229,6 +220,11 @@ private function test_license()
{
foreach ($this->validator->package_files as $filename)
{
+ if (mpv::check_unwanted($filename))
+ {
+ continue;
+ }
+
if (strtolower(basename($filename)) == 'license.txt')
{
return true;
@@ -249,6 +245,11 @@ private function test_prosilver_english()
$return = true;
foreach ($this->validator->package_files as $filename)
{
+ if (mpv::check_unwanted($filename))
+ {
+ continue;
+ }
+
$file = strtolower(basename($filename));
if ($file == 'prosilver.xml' || (strpos($file, 'prosilver') !== false && strpos($file, '.xml') !== false))
@@ -275,14 +276,11 @@ private function test_prosilver_english()
*/
private function test_unwanted()
{
- /**
- * @TODO: Does this work? I never saw a notice regarding it?
- */
// precache regexp for efficiency
- $regexp = '#(^|.*/)(' . implode('|', array_map('preg_quote', $this->unwanted_files)) . ')(?:/|$)#i';
+ $regexp = '#(^|.*/)(' . implode('|', array_map('preg_quote', mpv::$unwanted_files)) . ')(?:/|$)#i';
$unwanted_files = array();
- foreach ($this->validator->package_files as $filename)
+ foreach (mpv::$package_directories as $filename)
{
if (preg_match($regexp, $filename, $matches))
{
@@ -302,7 +300,7 @@ private function test_unwanted()
}
// push notice
- $this->push_error(mpv::ERROR_NOTICE, 'UNWANTED_FILE', null, array($matches[1], $matches[2]));
+ $this->push_error(mpv::ERROR_FAIL, 'UNWANTED_FILE', null, array($matches[1], $matches[2]));
}
}
View
@@ -44,6 +44,10 @@
// Use the _exact_ directory name
define('MPV_LANG', 'en');
+// Files that generate a warning, and that _arent_ checked.
+// Seperate with |
+define('UNWANTED', '__macosx|.ds_store|thumbs.db|.svn|.git|.project');
+
// This is for statistics gathering
// Format is: 'tag' => array('properties')
$statistics = array(
Submodule mpv_79018bc398526d94c8c9f54d14a7c172 added at a976d5
Submodule mpv_a7e94281214d68f87f35650c7c530d99 added at a976d5
View
Binary file not shown.

2 comments on commit d5826a3

@jellydoughnut

Probably want to git ignore the store directory :)

@paul999
Member

I noticed yeah :)

Please sign in to comment.