public function addMain($file) { $content = file_get_contents($file); $content = self::stripWhitespace(self::stripShebang($content)); $content = preg_replace("/(.+new[\\w \\\\]+Application\\('\\w+',).+?(\\);.+)/s", '$1\'' . Git::getVersion($this->config->getBasePath()) . '\'$2', $content); $this->phar->addFromString(FileUtils::pathDiff($this->config->getBasePath(), $file, true), $content); }
public function testSoftRealpath() { $this->assertEquals("/user/some/path", FileUtils::softRealpath("/user/blah-_0938!#\$%&'()+,;=@[]^`{}~/../some/path")); $this->assertEquals("/user/blah-_0938!#\$%&'()+,;=@[]^`{}~/some/path", FileUtils::softRealpath("/user/blah-_0938!#\$%&'()+,;=@[]^`{}~/./some/path")); $this->assertEquals("/user/blah-_0938!#\$%&'()+,;=@[]^`{}~/some/path", FileUtils::softRealpath("/user/blah-_0938!#\$%&'()+,;=@[]^`{}~//some/path")); $this->assertEquals("user/some/path", FileUtils::softRealpath("user/blah-_0938!#\$%&'()+,;=@[]^`{}~/../some/path")); $this->assertEquals("user/blah-_0938!#\$%&'()+,;=@[]^`{}~/some/path", FileUtils::softRealpath("user/blah-_0938!#\$%&'()+,;=@[]^`{}~/./some/path")); $this->assertEquals("user/blah-_0938!#\$%&'()+,;=@[]^`{}~/some/path", FileUtils::softRealpath("user/blah-_0938!#\$%&'()+,;=@[]^`{}~//some/path")); }