Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sql:query fails when given a Gzip file with path starting with ../ #5688

Closed
phparkle opened this issue Jul 6, 2023 · 1 comment · Fixed by #5689
Closed

sql:query fails when given a Gzip file with path starting with ../ #5688

phparkle opened this issue Jul 6, 2023 · 1 comment · Fixed by #5689

Comments

@phparkle
Copy link
Contributor

phparkle commented Jul 6, 2023

Describe the bug
When importing a gzipped sql file using sql:query --file=../dump.sql.gz, drush extracts the file then crashes with File(s) not found: dump.sql.

To Reproduce

  1. Place a gzipped sql file (dump.sql.gz) in the directory above Drupal root.
  2. Run drush sql:query --file=../dump.sql.gz. Note that the file path starts with ../ to point to the directory above Drupal root.

Expected behavior
Drush extracts and runs the sql file.

Actual behavior
Drush extracts the file but fails to run it.

System Configuration

Q A
Drush version? 12.1.1
Drupal version? 10.1.0
PHP version 8.1
OS? Linux
@phparkle
Copy link
Contributor Author

phparkle commented Jul 6, 2023

The problem is how the file path is trimmed after file decompression:

https://github.com/drush-ops/drush/blob/2dd7b48cd9ea07973687055a48903dfe5aba28e4/src/Sql/SqlBase.php#L326C27-L326C27

if ($process->isSuccessful()) {
  $input_file = trim($input_file, '.gz');
}

trim($input_file, '.gz') means the characters ., g and z will be trimmed from both ends of the string. So if the given path starts with ../, thd dots will be trimmed from the beginning.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant