]> granicus.if.org Git - php/commitdiff
increase code coverage and fix tiny bug in handling of absolute links
authorGreg Beaver <cellog@php.net>
Sun, 11 May 2008 22:59:16 +0000 (22:59 +0000)
committerGreg Beaver <cellog@php.net>
Sun, 11 May 2008 22:59:16 +0000 (22:59 +0000)
ext/phar/tests/tar/files/biglink.tar [new file with mode: 0644]
ext/phar/tests/tar/links3.phpt [new file with mode: 0644]
ext/phar/util.c

diff --git a/ext/phar/tests/tar/files/biglink.tar b/ext/phar/tests/tar/files/biglink.tar
new file mode 100644 (file)
index 0000000..43bbf58
Binary files /dev/null and b/ext/phar/tests/tar/files/biglink.tar differ
diff --git a/ext/phar/tests/tar/links3.phpt b/ext/phar/tests/tar/links3.phpt
new file mode 100644 (file)
index 0000000..2241081
--- /dev/null
@@ -0,0 +1,19 @@
+--TEST--
+Phar: tar with link to absolute path
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--FILE--
+<?php
+try {
+       $p = new PharData(dirname(__FILE__) . '/files/biglink.tar');
+} catch (Exception $e) {
+       echo $e->getMessage() . "\n";
+}
+echo $p['file.txt']->getContent();
+echo $p['my/file']->getContent();
+?>
+===DONE===
+--EXPECT--
+my file
+my file
+===DONE===
index ddd51eb6fecf8807c5298848b28c431f5a5ea84e..09258b1f96bc3e518fc2debb2db2063e2a98ef45 100644 (file)
@@ -33,7 +33,7 @@ static char *phar_get_link_location(phar_entry_info *entry TSRMLS_DC)
                return NULL;
        }
        if (entry->link[0] == '/') {
-               return entry->link;
+               return estrdup(entry->link + 1);
        }
        tmp = estrndup(entry->filename, entry->filename_len);
        p = strrchr(tmp, '/');