From 581650640518713b035b0164752acbc4211809e6 Mon Sep 17 00:00:00 2001 From: John Mertic Date: Wed, 9 Nov 2011 23:09:03 -0500 Subject: [PATCH] Release 6.4.0beta4 --- ModuleInstall/ModuleScanner.php | 175 ++++++++++-------- cron.php | 12 +- data/SugarBean.php | 11 +- download.php | 6 +- files.md5 | 100 +++++----- include/EditView/EditView.tpl | 4 + include/ListView/ListViewData.php | 2 +- include/database/MssqlManager.php | 2 +- include/database/MysqlManager.php | 2 + include/export_utils.php | 7 +- include/javascript/quicksearch.js | 2 +- include/javascript/sugar_3.js | 10 +- include/utils/mvc_utils.php | 2 +- .../include/javascript/quicksearch.js | 2 +- .../src_files/include/javascript/sugar_3.js | 11 +- jssource/src_files/modules/Calendar/Cal.js | 7 +- .../src_files/modules/Users/UserEditView.js | 2 +- modules/Calendar/Cal.js | 4 +- .../PipelineBySalesStageDashlet.php | 4 +- modules/Documents/Document.php | 2 +- modules/EmailMan/EmailManDelivery.php | 2 +- modules/Emails/javascript/EmailUICompose.js | 32 +++- modules/Employees/Employee.php | 14 ++ modules/Employees/language/en_us.lang.php | 3 + modules/Employees/metadata/SearchFields.php | 2 +- modules/Import/controller.php | 3 + modules/Import/sources/ImportFile.php | 3 + modules/MailMerge/Step2.html | 22 +-- modules/MailMerge/controller.php | 21 ++- modules/ModuleBuilder/language/en_us.lang.php | 1 + .../ModuleBuilder/tpls/MBModule/fields.tpl | 2 +- modules/Notes/language/en_us.lang.php | 3 + modules/ProspectLists/ProspectList.php | 25 +-- modules/Studio/TabGroups/EditViewTabs.tpl | 2 +- modules/Studio/wizards/RenameModules.php | 6 + modules/Studio/wizards/RenameModules.tpl | 4 +- modules/UpgradeWizard/index.php | 5 + modules/UpgradeWizard/silentUpgrade.php | 22 ++- modules/UpgradeWizard/silentUpgrade_step1.php | 8 +- modules/UpgradeWizard/silentUpgrade_step2.php | 4 +- modules/UpgradeWizard/uw_utils.php | 36 +++- modules/Users/User.php | 38 ++-- modules/Users/UserEditView.js | 2 +- modules/Users/UserViewHelper.php | 3 +- modules/Users/metadata/SearchFields.php | 2 +- modules/Users/tpls/EditViewFooter.tpl | 7 +- modules/Users/tpls/EditViewHeader.tpl | 3 +- modules/Users/views/view.edit.php | 18 ++ sugar_version.php | 8 +- tests/include/database/Bug43466Test.php | 83 +++++---- tests/include/database/DBManagerTest.php | 26 +++ tests/modules/Import/ImportFileTest.php | 19 ++ tests/modules/Users/Bug47735Test.php | 99 ++++++++++ themes/default/css/style.css | 1 + 54 files changed, 590 insertions(+), 306 deletions(-) create mode 100755 tests/modules/Users/Bug47735Test.php diff --git a/ModuleInstall/ModuleScanner.php b/ModuleInstall/ModuleScanner.php index 9e4b32bb..93dc9d94 100644 --- a/ModuleInstall/ModuleScanner.php +++ b/ModuleInstall/ModuleScanner.php @@ -1,4 +1,4 @@ -'language', 'install_logichooks'=>'logic_hooks', 'post_execute'=>'post_execute', - + ); - + private $blackListExempt = array(); - + private $validExt = array('png', 'gif', 'jpg', 'css', 'js', 'php', 'txt', 'html', 'htm', 'tpl', 'pdf', 'md5', 'xml'); private $blackList = array( 'popen', @@ -120,9 +120,9 @@ class ModuleScanner{ 'exec', 'system', 'shell_exec', - 'passthru', + 'passthru', 'chgrp', - 'chmod', + 'chmod', 'chwown', 'file_put_contents', 'file', @@ -133,7 +133,7 @@ class ModuleScanner{ 'filemtime', 'fileowner', 'fileperms', - 'fopen', + 'fopen', 'is_executable', 'is_writable', 'is_writeable', @@ -152,7 +152,7 @@ class ModuleScanner{ 'call_user_func', 'call_user_func_array', 'create_function', - + //mutliple files per function call 'copy', @@ -182,14 +182,14 @@ class ModuleScanner{ echo "'''Default Extensions'''
"; foreach($this->validExt as $b){ echo '#' . $b . '
'; - + } echo "'''Default Black Listed Functions'''
"; foreach($this->blackList as $b){ echo '#' . $b . '
'; - + } - + } public function __construct(){ @@ -202,42 +202,42 @@ class ModuleScanner{ if(!empty($GLOBALS['sugar_config']['moduleInstaller']['validExt'])){ $this->validExt = array_merge($this->validExt, $GLOBALS['sugar_config']['moduleInstaller']['validExt']); } - + } private $issues = array(); private $pathToModule = ''; - + /** *returns a list of issues */ public function getIssues(){ return $this->issues; } - + /** *returns true or false if any issues were found */ public function hasIssues(){ return !empty($this->issues); } - + /** *Ensures that a file has a valid extension */ private function isValidExtension($file){ $file = strtolower($file); - + $extPos = strrpos($file, '.'); //make sure they don't override the files.md5 if($extPos === false || $file == 'files.md5')return false; $ext = substr($file, $extPos + 1); return in_array($ext, $this->validExt); - + } - + /** - *Scans a directory and calls on scan file for each file + *Scans a directory and calls on scan file for each file **/ public function scanDir($path){ static $startPath = ''; @@ -249,21 +249,40 @@ class ModuleScanner{ if(is_dir($next)){ if(substr($e, 0, 1) == '.')continue; $this->scanDir($next); - }else{ + }else{ $issues = $this->scanFile($next); - - + + } } return true; } - - + + /** + * Check if the file contents looks like PHP + * @param string $contents File contents + * @return boolean + */ + protected function isPHPFile($contents) + { + if(stripos($contents, 'isPHPFile($contents)) return $issues; + $tokens = @token_get_all($contents); $checkFunction = false; $possibleIssue = ''; $lastToken = false; @@ -285,7 +304,7 @@ class ModuleScanner{ $issues['backtick'] = translate('ML_INVALID_FUNCTION') . " '`'"; case '(': if($checkFunction)$issues[] = $possibleIssue; - break; + break; } $checkFunction = false; $possibleIssue = ''; @@ -301,8 +320,8 @@ class ModuleScanner{ $token[1] = strtolower($token[1]); if(!in_array($token[1], $this->blackList))break; if(in_array($token[1], $this->blackListExempt))break; - if ($lastToken !== false && - ($lastToken[0] == T_NEW || $lastToken[0] == T_OBJECT_OPERATOR || $lastToken[0] == T_DOUBLE_COLON)) + if ($lastToken !== false && + ($lastToken[0] == T_NEW || $lastToken[0] == T_OBJECT_OPERATOR || $lastToken[0] == T_DOUBLE_COLON)) { break; } @@ -310,7 +329,7 @@ class ModuleScanner{ $checkFunction = true; $possibleIssue = translate('ML_INVALID_FUNCTION') . ' ' . $token[1] . '()'; break; - + default: $checkFunction = false; $possibleIssue = ''; @@ -321,18 +340,18 @@ class ModuleScanner{ $lastToken = $token; } } - + } if(!empty($issues)){ $this->issues['file'][$file] = $issues; } - - return $issues; + + return $issues; } - - + + /* - * checks files.md5 file to see if the file is from sugar + * checks files.md5 file to see if the file is from sugar * ONLY WORKS ON FILES */ public function sugarFileExists($path){ @@ -343,11 +362,11 @@ class ModuleScanner{ $md5 = $md5_string; } if(isset($md5['./' . $path]))return true; - - + + } - - + + /** *This function will scan the Manifest for disabled actions specified in $GLOBALS['sugar_config']['moduleInstaller']['disableActions'] *if $GLOBALS['sugar_config']['moduleInstaller']['disableRestrictedCopy'] is set to false or not set it will call on scanCopy to ensure that it is not overriding files @@ -364,9 +383,9 @@ class ModuleScanner{ return $fileIssues; } include($manifestPath); - - - //scan for disabled actions + + + //scan for disabled actions if(isset($GLOBALS['sugar_config']['moduleInstaller']['disableActions'])){ foreach($GLOBALS['sugar_config']['moduleInstaller']['disableActions'] as $action){ if(isset($installdefs[$this->manifestMap[$action]])){ @@ -374,8 +393,8 @@ class ModuleScanner{ } } } - - //now lets scan for files that will override our files + + //now lets scan for files that will override our files if(empty($GLOBALS['sugar_config']['moduleInstaller']['disableRestrictedCopy']) && isset($installdefs['copy'])){ foreach($installdefs['copy'] as $copy){ $from = str_replace('', $this->pathToModule, $copy['from']); @@ -391,25 +410,25 @@ class ModuleScanner{ } while(substr_count($to, '//')){ $to = str_replace('//', '/', $to); - } + } $this->scanCopy($from, $to); } } if(!empty($issues)){ $this->issues['manifest'][$manifestPath] = $issues; } - - - + + + } - - + + /** - * Takes in where the file will is specified to be copied from and to - * and ensures that there is no official sugar file there. If the file exists it will check + * Takes in where the file will is specified to be copied from and to + * and ensures that there is no official sugar file there. If the file exists it will check * against the MD5 file list to see if Sugar Created the file - * + * */ function scanCopy($from, $to){ //if the file doesn't exist for the $to then it is not overriding anything @@ -421,28 +440,28 @@ class ModuleScanner{ } $to .= '/'. basename($from); } - //if the $to is a file and it is found in sugarFileExists then don't allow overriding it + //if the $to is a file and it is found in sugarFileExists then don't allow overriding it if(is_file($to) && $this->sugarFileExists($to)){ $this->issues['copy'][$from] = translate('ML_OVERRIDE_CORE_FILES') . '(' . $to . ')'; } - + if(is_dir($from)){ $d = dir($from); while($e = $d->read()){ if($e == '.' || $e == '..')continue; - $this->scanCopy($from .'/'. $e, $to .'/' . $e); + $this->scanCopy($from .'/'. $e, $to .'/' . $e); } } - - - - - + + + + + } - - + + /** - *Main external function that takes in a path to a package and then scans + *Main external function that takes in a path to a package and then scans *that package's manifest for disabled actions and then it scans the PHP files *for restricted function calls * @@ -454,22 +473,22 @@ class ModuleScanner{ $this->scanDir($path); } } - + /** - *This function will take all issues of the current instance and print them to the screen + *This function will take all issues of the current instance and print them to the screen **/ public function displayIssues($package='Package'){ - echo '

'.str_replace('{PACKAGE}' , $package ,translate('ML_PACKAGE_SCANNING')). '


' . translate('ML_INSTALLATION_FAILED') . '


' .str_replace('{PACKAGE}' , $package ,translate('ML_PACKAGE_NOT_CONFIRM')). '