Guest User

php-71966

a guest
Feb 21st, 2017
100
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2. mkdir php-tar-bug
  3. cd php-tar-bug
  4. echo 'hello world' > file1
  5. echo 'hello world' > file2
  6.  
  7. tar cf ../php-tar-bug.tar .
  8. echo 'Listing contents with `tar`:'
  9. tar tf ../php-tar-bug.tar
  10. echo ""
  11. php <<EOF
  12. <?php
  13. \$phar = new PharData("../php-tar-bug.tar");
  14. echo "PHP sees archive contains " . count(\$phar) . " files:\n";
  15.  
  16. foreach (\$phar as \$k => \$v) {
  17. // Loop is not entered!
  18. echo " -> \$k\n";
  19. }
  20. echo "\n";
  21. try {
  22. // File is not found! BadMethodCallException
  23. \$phar["file1"];
  24. } catch (Exception \$e) {
  25. echo \$e;
  26. }
  27. echo "\n";
  28. try {
  29. // File cannot be accessed! (RuntimeException)
  30. \$phar["./file1"];
  31. } catch (Exception \$e) {
  32. echo \$e;
  33. }
  34. echo "\n";
  35. \$phar = new PharData("../php-tar-bug.tar", Phar::CURRENT_AS_FILEINFO | Phar::KEY_AS_FILENAME);
  36. // This produces a fatal error!
  37. foreach (\$phar as \$k => \$v) {}
  38. EOF
RAW Paste Data