<commit_before><?php
namespace wcf\data\application;
use wcf\data\package\Package;
use wcf\data\package\PackageCache;
use wcf\data\package\PackageList;
use wcf\data\DatabaseObject;
use wcf\system\application\ApplicationHandler;
use wcf\system\exception\SystemException;
use wcf\system\request\RouteHandler;
use wcf\util\FileUtil;

/**
 * Represents an application.
 * 
 * @author	<NAME>
 * @copyright	2001-2017 WoltLab GmbH
 * @license	GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
 * @package	WoltLabSuite\Core\Data\Application
 *
 * @property-read	integer		$packageID	id of the package which delivers the application
 * @property-read	string		$domainName	domain used to access the application (may not contain path components, see `$domainPath`)
 * @property-read	string		$domainPath	path used to access the application
 * @property-read	string		$cookieDomain	domain used to set cookies (corresponds to `domain` cookie property; may not contain path components)
 * @property-read	integer		$isTainted	is `1` if the application is being uninstalled and thus should not be loaded during uninstallation, otherwise `0`
 * @property-read       integer         $landingPageID  id of the page that is used as initial page when app is accessed without a controller name
 */
class Application extends DatabaseObject {
	/**
	 * related package object
	 * @var	Package
	 */
	protected $package;
	
	/**
	 * absolute page URL
	 * @var	string
	 */
	protected $pageURL = '';
	
	/**
	 * @inheritDoc
	 */
	protected static $databaseTableIndexName = 'packageID';
	
	/**
	 * @inheritDoc
	 */
	protected static $databaseTableIndexIsIdentity = false;
	
	/**
	 * list of all available application directories
	 * @var	string[]
	 */
	protected static $directories = null;
	
	/**
	 * Returns the abbreviation of the application.
	 * 
	 * @return	string
	 */
	public function getAbbreviation() {
		return ApplicationHandler::getInstance()->getAbbreviation($this->packageID);
	}
	
	/**
	 * Returns related package object.
	 * 
	 * @return	Package		related package object
	 */
	public function getPackage() {
		if ($this->package === null) {<commit_msg>Safeguard against malformed domain paths caused by direct database manipulations<commit_after><?php
namespace wcf\data\application;
use wcf\data\package\Package;
use wcf\data\package\PackageCache;
use wcf\data\package\PackageList;
use wcf\data\DatabaseObject;
use wcf\system\application\ApplicationHandler;
use wcf\system\exception\SystemException;
use wcf\system\request\RouteHandler;
use wcf\util\FileUtil;

/**
 * Represents an application.
 * 
 * @author	<NAME>
 * @copyright	2001-2017 WoltLab GmbH
 * @license	GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
 * @package	WoltLabSuite\Core\Data\Application
 *
 * @property-read	integer		$packageID	id of the package which delivers the application
 * @property-read	string		$domainName	domain used to access the application (may not contain path components, see `$domainPath`)
 * @property-read	string		$domainPath	path used to access the application
 * @property-read	string		$cookieDomain	domain used to set cookies (corresponds to `domain` cookie property; may not contain path components)
 * @property-read	integer		$isTainted	is `1` if the application is being uninstalled and thus should not be loaded during uninstallation, otherwise `0`
 * @property-read       integer         $landingPageID  id of the page that is used as initial page when app is accessed without a controller name
 */
class Application extends DatabaseObject {
	/**
	 * related package object
	 * @var	Package
	 */
	protected $package;
	
	/**
	 * absolute page URL
	 * @var	string
	 */
	protected $pageURL = '';
	
	/**
	 * @inheritDoc
	 */
	protected static $databaseTableIndexName = 'packageID';
	
	/**
	 * @inheritDoc
	 */
	protected static $databaseTableIndexIsIdentity = false;
	
	/**
	 * list of all available application directories
	 * @var	string[]
	 */
	protected static $directories = null;
	
	/**
	 * @inheritDoc
	 */
	protected function handleData($data) {
		if (isset($data['domainPath'])) {
			// The leading and trailing slashes are required and enforced through the admin panel,
			// however, some users edit the database directly and omit them, causing incorrect urls.
			$data['domainPath'] = FileUtil::addLeadingSlash(FileUtil::addTrailingSlash($data['domainPath']));
		}
		
		parent::handleData($data);
	}
	
	/**
	 * Returns the abbreviation of the application.
	 * 
	 * @return	string
	 */
	public function getAbbreviation() {
		return ApplicationHandler::getInstance()->getAbbreviation($this->packageID);
	}
	
	/**
	 * Returns related package object.
	 * 
	 * @return	Package		related package object
	 */
	public function getPackage() {
		if ($this->package === null) {
{'fraction_non_alphanumeric': 0.10221853618080033, 'fraction_numerical': 0.004146796599626789, 'mean_word_length': 4.093980992608237, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3436091', 'n_tokens_mistral': 1467, 'n_tokens_neox': 1331, 'n_words': 446}