Skip to content

Commit 1d434bb

Browse files
committed
Fix closing title tag
Unfortunately, ext/phar/stub.h and ext/phar/makestub.php seem to be out of sync, so ext/phar/stub.h was adjusted manually. This should be fixed separately. See GH-19633
1 parent 96c0bc5 commit 1d434bb

11 files changed

+36
-36
lines changed

ext/phar/shortarc.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
$a = realpath(Extract_Phar::$temp . DIRECTORY_SEPARATOR . $pt);
7575
if (!$a || strlen(dirname($a)) < strlen(Extract_Phar::$temp)) {
7676
header('HTTP/1.0 404 Not Found');
77-
echo "<html>\n <head>\n <title>File Not Found<title>\n </head>\n <body>\n <h1>404 - File Not Found</h1>\n </body>\n</html>";
77+
echo "<html>\n <head>\n <title>File Not Found</title>\n </head>\n <body>\n <h1>404 - File Not Found</h1>\n </body>\n</html>";
7878
exit;
7979
}
8080
$b = pathinfo($a);

ext/phar/stub.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ static inline zend_string* phar_get_stub(const char *index_php, const char *web,
2020
{
2121
static const char newstub0[] = "<?php\n\n$web = '";
2222
static const char newstub1_0[] = "';\n\nif (in_array('phar', stream_get_wrappers()) && class_exists('Phar', 0)) {\nPhar::interceptFileFuncs();\nset_include_path('phar://' . __FILE__ . PATH_SEPARATOR . get_include_path());\nPhar::webPhar(null, $web);\ninclude 'phar://' . __FILE__ . '/' . Extract_Phar::START;\nreturn;\n}\n\nif (@(isset($_SERVER['REQUEST_URI']) && isset($_SERVER['REQUEST_METHOD']) && ($_SERVER['REQUEST_METHOD'] == 'GET' || $_SERVER['REQUEST_METHOD'] == 'POST'))) {\nExtract_Phar::go(true);\n$mimes = array(\n'phps' => 2,\n'c' => 'text/plain',\n'cc' => 'text/plain',\n'cpp' => 'text/plain',\n'c++' => 'text/plain',\n'dtd' => 'text/plain',\n'h' => 'text/plain',\n'log' => 'text/plain',\n'rng' => 'text/plain',\n'txt' => 'text/plain',\n'xsd' => 'text/plain',\n'php' => 1,\n'inc' => 1,\n'avi' => 'video/avi',\n'bmp' => 'image/bmp',\n'css' => 'text/css',\n'gif' => 'image/gif',\n'htm' => 'text/html',\n'html' => 'text/html',\n'htmls' => 'text/html',\n'ico' => 'image/x-ico',\n'jpe' => 'image/jpeg',\n'jpg' => 'image/jpeg',\n'jpeg' => 'image/jpeg',\n'js' => 'application/x-javascript',\n'midi' => 'audio/midi',\n'mid' => 'audio/midi',\n'mod' => 'audio/mod',\n'mov' => 'movie/quicktime',\n'mp3' => 'audio/mp3',\n'mpg' => 'video/mpeg',\n'mpeg' => 'video/mpeg',\n'pdf' => 'application/pdf',\n'png' => 'image/png',\n'swf' => 'application/shockwave-flash',\n'tif' => 'image/tiff',\n'tiff' => 'image/tiff',\n'wav' => 'audio/wav',\n'xbm' => 'image/xbm',\n'xml' => 'text/xml',\n);\n\nheader(\"Cache-Control: no-cache, must-revalidate\");\nheader(\"Pragma: no-cache\");\n\n$basename = basename(__FILE__);\nif (!strpos($_SERVER['REQUEST_URI'], $basename)) {\nchdir(Extract_Phar::$temp);\ninclude $web;\nreturn;\n}\n$pt = substr($_SERVER['REQUEST_URI'], strpos($_SERVER['REQUEST_URI'], $basename) + strlen($basename));\nif (!$pt || $pt == '/') {\n$pt = $web;\nheader('HTTP/1.1 301 Moved Permanently');\nheader('Location: ' . $_SERVER['REQUEST_URI'] . '/' . $pt);\nexit;\n}\n$a = realpath(Extract_Phar::$temp . DIRECTORY_SEPARATOR . $pt);\nif (!$a || strlen(dirname($a)) < strlen(";
23-
static const char newstub1_1[] = "Extract_Phar::$temp)) {\nheader('HTTP/1.0 404 Not Found');\necho \"<html>\\n <head>\\n <title>File Not Found<title>\\n </head>\\n <body>\\n <h1>404 - File Not Found</h1>\\n </body>\\n</html>\";\nexit;\n}\n$b = pathinfo($a);\nif (!isset($b['extension'])) {\nheader('Content-Type: text/plain');\nheader('Content-Length: ' . filesize($a));\nreadfile($a);\nexit;\n}\nif (isset($mimes[$b['extension']])) {\nif ($mimes[$b['extension']] === 1) {\ninclude $a;\nexit;\n}\nif ($mimes[$b['extension']] === 2) {\nhighlight_file($a);\nexit;\n}\nheader('Content-Type: ' .$mimes[$b['extension']]);\nheader('Content-Length: ' . filesize($a));\nreadfile($a);\nexit;\n}\n}\n\nclass Extract_Phar\n{\nstatic $temp;\nstatic $origdir;\nconst GZ = 0x1000;\nconst BZ2 = 0x2000;\nconst MASK = 0x3000;\nconst START = '";
23+
static const char newstub1_1[] = "Extract_Phar::$temp)) {\nheader('HTTP/1.0 404 Not Found');\necho \"<html>\\n <head>\\n <title>File Not Found</title>\\n </head>\\n <body>\\n <h1>404 - File Not Found</h1>\\n </body>\\n</html>\";\nexit;\n}\n$b = pathinfo($a);\nif (!isset($b['extension'])) {\nheader('Content-Type: text/plain');\nheader('Content-Length: ' . filesize($a));\nreadfile($a);\nexit;\n}\nif (isset($mimes[$b['extension']])) {\nif ($mimes[$b['extension']] === 1) {\ninclude $a;\nexit;\n}\nif ($mimes[$b['extension']] === 2) {\nhighlight_file($a);\nexit;\n}\nheader('Content-Type: ' .$mimes[$b['extension']]);\nheader('Content-Length: ' . filesize($a));\nreadfile($a);\nexit;\n}\n}\n\nclass Extract_Phar\n{\nstatic $temp;\nstatic $origdir;\nconst GZ = 0x1000;\nconst BZ2 = 0x2000;\nconst MASK = 0x3000;\nconst START = '";
2424
static const char newstub2[] = "';\nconst LEN = ";
2525
static const char newstub3_0[] = ";\n\nstatic function go($return = false)\n{\n$fp = fopen(__FILE__, 'rb');\nfseek($fp, self::LEN);\n$L = unpack('V', $a = fread($fp, 4));\n$m = '';\n\ndo {\n$read = 8192;\nif ($L[1] - strlen($m) < 8192) {\n$read = $L[1] - strlen($m);\n}\n$last = fread($fp, $read);\n$m .= $last;\n} while (strlen($last) && strlen($m) < $L[1]);\n\nif (strlen($m) < $L[1]) {\ndie('ERROR: manifest length read was \"' .\nstrlen($m) .'\" should be \"' .\n$L[1] . '\"');\n}\n\n$info = self::_unpack($m);\n$f = $info['c'];\n\nif ($f & self::GZ) {\nif (!function_exists('gzinflate')) {\ndie('Error: zlib extension is not enabled -' .\n' gzinflate() function needed for zlib-compressed .phars');\n}\n}\n\nif ($f & self::BZ2) {\nif (!function_exists('bzdecompress')) {\ndie('Error: bzip2 extension is not enabled -' .\n' bzdecompress() function needed for bz2-compressed .phars');\n}\n}\n\n$temp = self::tmpdir();\n\nif (!$temp || !is_writable($temp)) {\n$sessionpath = session_save_path();\nif (strpos ($sessionpath, \";\") !== false)\n$sessionpath = substr ($sessionpath, strpos ($sessionpath, \";\")+1);\nif (!file_exists($sessionpath) || !is_dir($sessionpath)) {\ndie('Could not locate temporary directory to extract phar');\n}\n$temp = $sessionpath;\n}\n\n$temp .= '/pharextract/'.basename(__FILE__, '.phar');\nself::$temp = $temp;\nself::$origdir = getcwd();\n@mkdir($temp, 0777, true);\n$temp = realpath($temp);\n\nif (!file_exists($temp . DIRECTORY_SEPARATOR . md5_file(__FILE__))) {\nself::_removeTmpFiles($temp, getcwd());\n@mkdir($temp, 0777, true);\n@file_put_contents($temp . '/' . md5_file(__FILE__), '');\n\nforeach ($info['m'] as $path => $file) {\n$a = !file_exists(dirname($temp . '/' . $path));\n@mkdir(dirname($temp . '/' . $path), 0777, true);\nclearstatcache();\n\nif ($path[strlen($path) - 1] == '/') {\n@mkdir($temp . '/' . $path, 0777);\n} else {\nfile_put_contents($temp . '/' . $path, self::extractFile($path, $file, $fp));\n@chmod($temp . '/' . $path, 0666);\n}\n}\n}\n\nchdir($temp);\n\nif (!$return) {\ninclude self::START;\n}\n}\n\nstatic fun";
2626
static const char newstub3_1[] = "ction tmpdir()\n{\nif (strpos(PHP_OS, 'WIN') !== false) {\nif ($var = getenv('TMP') ? getenv('TMP') : getenv('TEMP')) {\nreturn $var;\n}\nif (is_dir('/temp') || mkdir('/temp')) {\nreturn realpath('/temp');\n}\nreturn false;\n}\nif ($var = getenv('TMPDIR')) {\nreturn $var;\n}\nreturn realpath('/tmp');\n}\n\nstatic function _unpack($m)\n{\n$info = unpack('V', substr($m, 0, 4));\n $l = unpack('V', substr($m, 10, 4));\n$m = substr($m, 14 + $l[1]);\n$s = unpack('V', substr($m, 0, 4));\n$o = 0;\n$start = 4 + $s[1];\n$ret['c'] = 0;\n\nfor ($i = 0; $i < $info[1]; $i++) {\n $len = unpack('V', substr($m, $start, 4));\n$start += 4;\n $savepath = substr($m, $start, $len[1]);\n$start += $len[1];\n $ret['m'][$savepath] = array_values(unpack('Va/Vb/Vc/Vd/Ve/Vf', substr($m, $start, 24)));\n$ret['m'][$savepath][3] = sprintf('%u', $ret['m'][$savepath][3]\n& 0xffffffff);\n$ret['m'][$savepath][7] = $o;\n$o += $ret['m'][$savepath][2];\n$start += 24 + $ret['m'][$savepath][5];\n$ret['c'] |= $ret['m'][$savepath][4] & self::MASK;\n}\nreturn $ret;\n}\n\nstatic function extractFile($path, $entry, $fp)\n{\n$data = '';\n$c = $entry[2];\n\nwhile ($c) {\nif ($c < 8192) {\n$data .= @fread($fp, $c);\n$c = 0;\n} else {\n$c -= 8192;\n$data .= @fread($fp, 8192);\n}\n}\n\nif ($entry[4] & self::GZ) {\n$data = gzinflate($data);\n} elseif ($entry[4] & self::BZ2) {\n$data = bzdecompress($data);\n}\n\nif (strlen($data) != $entry[0]) {\ndie(\"Invalid internal .phar file (size error \" . strlen($data) . \" != \" .\n$stat[7] . \")\");\n}\n\nif ($entry[3] != sprintf(\"%u\", crc32($data) & 0xffffffff)) {\ndie(\"Invalid internal .phar file (checksum error)\");\n}\n\nreturn $data;\n}\n\nstatic function _removeTmpFiles($temp, $origdir)\n{\nchdir($temp);\n\nforeach (glob('*') as $f) {\nif (file_exists($f)) {\nis_dir($f) ? @rmdir($f) : @unlink($f);\nif (file_exists($f) && is_dir($f)) {\nself::_removeTmpFiles($f, getcwd());\n}\n}\n}\n\n@rmdir($temp);\nclearstatcache();\nchdir($origdir);\n}\n}\n\nExtract_Phar::go();\n__HALT_COMPILER(); ?>";
2727

28-
static const int newstub_len = 6623;
28+
static const int newstub_len = 6624;
2929

3030
return strpprintf(name_len + web_len + newstub_len, "%s%s%s%s%s%s%d%s%s", newstub0, web, newstub1_0, newstub1_1, index_php, newstub2, name_len + web_len + newstub_len, newstub3_0, newstub3_1);
3131
}

ext/phar/tests/cache_list/copyonwrite11.phar.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@ echo strlen($p2->getStub()),"\n";
1818
echo "ok\n";
1919
__HALT_COMPILER(); ?>
2020
"
21-
6643
21+
6644
2222
ok

ext/phar/tests/phar_commitwrite.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ unlink(__DIR__ . '/phar_commitwrite.phar');
2727
__HALT_COMPILER();
2828
?>
2929
--EXPECTF--
30-
int(6641)
30+
int(6642)
3131
string(%d) "<?php
3232
spl_autoload_register(function($class) {
3333
include 'phar://' . str_replace('_', '/', $class);

ext/phar/tests/phar_convert_repeated.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ NULL
120120
bool(true)
121121
bool(false)
122122
bool(false)
123-
int(6641)
123+
int(6642)
124124
NULL
125125
================= convertToZip() =====================
126126
bool(false)

ext/phar/tests/phar_create_in_cwd.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ __HALT_COMPILER();
3030
unlink(__DIR__ . '/phar_create_in_cwd.phar');
3131
?>
3232
--EXPECTF--
33-
int(6641)
33+
int(6642)
3434
string(%d) "<?php
3535
spl_autoload_register(function($class) {
3636
include 'phar://' . str_replace('_', '/', $class);

ext/phar/tests/phar_createdefaultstub.phpt

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ echo $e->getMessage() . "\n";
3333
}
3434
?>
3535
--EXPECT--
36-
string(6641) "<?php
36+
string(6642) "<?php
3737

3838
$web = 'index.php';
3939

@@ -109,7 +109,7 @@ exit;
109109
$a = realpath(Extract_Phar::$temp . DIRECTORY_SEPARATOR . $pt);
110110
if (!$a || strlen(dirname($a)) < strlen(Extract_Phar::$temp)) {
111111
header('HTTP/1.0 404 Not Found');
112-
echo "<html>\n <head>\n <title>File Not Found<title>\n </head>\n <body>\n <h1>404 - File Not Found</h1>\n </body>\n</html>";
112+
echo "<html>\n <head>\n <title>File Not Found</title>\n </head>\n <body>\n <h1>404 - File Not Found</h1>\n </body>\n</html>";
113113
exit;
114114
}
115115
$b = pathinfo($a);
@@ -143,7 +143,7 @@ const GZ = 0x1000;
143143
const BZ2 = 0x2000;
144144
const MASK = 0x3000;
145145
const START = 'index.php';
146-
const LEN = 6643;
146+
const LEN = 6644;
147147

148148
static function go($return = false)
149149
{
@@ -327,7 +327,7 @@ Extract_Phar::go();
327327
__HALT_COMPILER(); ?>"
328328
============================================================================
329329
============================================================================
330-
string(6652) "<?php
330+
string(6653) "<?php
331331

332332
$web = 'index.php';
333333

@@ -403,7 +403,7 @@ exit;
403403
$a = realpath(Extract_Phar::$temp . DIRECTORY_SEPARATOR . $pt);
404404
if (!$a || strlen(dirname($a)) < strlen(Extract_Phar::$temp)) {
405405
header('HTTP/1.0 404 Not Found');
406-
echo "<html>\n <head>\n <title>File Not Found<title>\n </head>\n <body>\n <h1>404 - File Not Found</h1>\n </body>\n</html>";
406+
echo "<html>\n <head>\n <title>File Not Found</title>\n </head>\n <body>\n <h1>404 - File Not Found</h1>\n </body>\n</html>";
407407
exit;
408408
}
409409
$b = pathinfo($a);
@@ -437,7 +437,7 @@ const GZ = 0x1000;
437437
const BZ2 = 0x2000;
438438
const MASK = 0x3000;
439439
const START = 'my/custom/thingy.php';
440-
const LEN = 6654;
440+
const LEN = 6655;
441441

442442
static function go($return = false)
443443
{
@@ -621,15 +621,15 @@ Extract_Phar::go();
621621
__HALT_COMPILER(); ?>"
622622
============================================================================
623623
============================================================================
624-
int(7032)
624+
int(7033)
625625
============================================================================
626626
============================================================================
627627
Illegal filename passed in for stub creation, was 401 characters long, and only 400 or less is allowed
628628
============================================================================
629629
============================================================================
630630
============================================================================
631631
============================================================================
632-
string(6654) "<?php
632+
string(6655) "<?php
633633

634634
$web = 'the/web.php';
635635

@@ -705,7 +705,7 @@ exit;
705705
$a = realpath(Extract_Phar::$temp . DIRECTORY_SEPARATOR . $pt);
706706
if (!$a || strlen(dirname($a)) < strlen(Extract_Phar::$temp)) {
707707
header('HTTP/1.0 404 Not Found');
708-
echo "<html>\n <head>\n <title>File Not Found<title>\n </head>\n <body>\n <h1>404 - File Not Found</h1>\n </body>\n</html>";
708+
echo "<html>\n <head>\n <title>File Not Found</title>\n </head>\n <body>\n <h1>404 - File Not Found</h1>\n </body>\n</html>";
709709
exit;
710710
}
711711
$b = pathinfo($a);
@@ -739,7 +739,7 @@ const GZ = 0x1000;
739739
const BZ2 = 0x2000;
740740
const MASK = 0x3000;
741741
const START = 'my/custom/thingy.php';
742-
const LEN = 6656;
742+
const LEN = 6657;
743743

744744
static function go($return = false)
745745
{
@@ -923,5 +923,5 @@ Extract_Phar::go();
923923
__HALT_COMPILER(); ?>"
924924
============================================================================
925925
============================================================================
926-
int(7032)
926+
int(7033)
927927
Illegal web filename passed in for stub creation, was 401 characters long, and only 400 or less is allowed

ext/phar/tests/phar_offset_check.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ var_dump($phar->getAlias());
6868
Entry .phar/stub.php does not exist
6969
Entry .phar/alias.txt does not exist
7070
Cannot set stub ".phar/stub.php" directly in phar "%sphar_offset_check.phar.php", use setStub
71-
int(6643)
72-
int(6643)
71+
int(6644)
72+
int(6644)
7373
Cannot set alias ".phar/alias.txt" directly in phar "%sphar_offset_check.phar.php", use setAlias
7474
string(5) "susan"
7575
string(5) "susan"

ext/phar/tests/phar_setdefaultstub.phpt

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ try {
5353
unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.phar');
5454
?>
5555
--EXPECT--
56-
string(6643) "<?php
56+
string(6644) "<?php
5757

5858
$web = 'index.php';
5959

@@ -129,7 +129,7 @@ exit;
129129
$a = realpath(Extract_Phar::$temp . DIRECTORY_SEPARATOR . $pt);
130130
if (!$a || strlen(dirname($a)) < strlen(Extract_Phar::$temp)) {
131131
header('HTTP/1.0 404 Not Found');
132-
echo "<html>\n <head>\n <title>File Not Found<title>\n </head>\n <body>\n <h1>404 - File Not Found</h1>\n </body>\n</html>";
132+
echo "<html>\n <head>\n <title>File Not Found</title>\n </head>\n <body>\n <h1>404 - File Not Found</h1>\n </body>\n</html>";
133133
exit;
134134
}
135135
$b = pathinfo($a);
@@ -163,7 +163,7 @@ const GZ = 0x1000;
163163
const BZ2 = 0x2000;
164164
const MASK = 0x3000;
165165
const START = 'index.php';
166-
const LEN = 6643;
166+
const LEN = 6644;
167167

168168
static function go($return = false)
169169
{
@@ -348,7 +348,7 @@ __HALT_COMPILER(); ?>
348348
"
349349
============================================================================
350350
============================================================================
351-
string(6654) "<?php
351+
string(6655) "<?php
352352

353353
$web = 'index.php';
354354

@@ -424,7 +424,7 @@ exit;
424424
$a = realpath(Extract_Phar::$temp . DIRECTORY_SEPARATOR . $pt);
425425
if (!$a || strlen(dirname($a)) < strlen(Extract_Phar::$temp)) {
426426
header('HTTP/1.0 404 Not Found');
427-
echo "<html>\n <head>\n <title>File Not Found<title>\n </head>\n <body>\n <h1>404 - File Not Found</h1>\n </body>\n</html>";
427+
echo "<html>\n <head>\n <title>File Not Found</title>\n </head>\n <body>\n <h1>404 - File Not Found</h1>\n </body>\n</html>";
428428
exit;
429429
}
430430
$b = pathinfo($a);
@@ -458,7 +458,7 @@ const GZ = 0x1000;
458458
const BZ2 = 0x2000;
459459
const MASK = 0x3000;
460460
const START = 'my/custom/thingy.php';
461-
const LEN = 6654;
461+
const LEN = 6655;
462462

463463
static function go($return = false)
464464
{
@@ -643,7 +643,7 @@ __HALT_COMPILER(); ?>
643643
"
644644
============================================================================
645645
============================================================================
646-
string(6656) "<?php
646+
string(6657) "<?php
647647

648648
$web = 'the/web.php';
649649

@@ -719,7 +719,7 @@ exit;
719719
$a = realpath(Extract_Phar::$temp . DIRECTORY_SEPARATOR . $pt);
720720
if (!$a || strlen(dirname($a)) < strlen(Extract_Phar::$temp)) {
721721
header('HTTP/1.0 404 Not Found');
722-
echo "<html>\n <head>\n <title>File Not Found<title>\n </head>\n <body>\n <h1>404 - File Not Found</h1>\n </body>\n</html>";
722+
echo "<html>\n <head>\n <title>File Not Found</title>\n </head>\n <body>\n <h1>404 - File Not Found</h1>\n </body>\n</html>";
723723
exit;
724724
}
725725
$b = pathinfo($a);
@@ -753,7 +753,7 @@ const GZ = 0x1000;
753753
const BZ2 = 0x2000;
754754
const MASK = 0x3000;
755755
const START = 'my/custom/thingy.php';
756-
const LEN = 6656;
756+
const LEN = 6657;
757757

758758
static function go($return = false)
759759
{
@@ -938,5 +938,5 @@ __HALT_COMPILER(); ?>
938938
"
939939
============================================================================
940940
============================================================================
941-
int(7034)
941+
int(7035)
942942
Illegal filename passed in for stub creation, was 401 characters long, and only 400 or less is allowed

ext/phar/tests/tar/phar_convert_phar.phpt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ __HALT_COMPILER();
4545
?>
4646
--EXPECT--
4747
bool(false)
48-
int(6641)
48+
int(6642)
4949
bool(true)
5050
string(60) "<?php // tar-based phar archive stub file
5151
__HALT_COMPILER();"
5252
bool(true)
53-
int(6641)
53+
int(6642)
5454
bool(true)
55-
int(6641)
55+
int(6642)

0 commit comments

Comments
 (0)