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

Download fails when plugin directory name includes uppercase characters #83

Closed
theschmocker opened this issue Nov 19, 2018 · 2 comments
Closed

Comments

@theschmocker
Copy link

We have a plugin that we would like to include in our Satispress installation. We ran into an issue, where if the plugin directory contains uppercase characters, any attempt to download it fails with a 404 (from both composer and the Satispress backend). Ex: "eventON". Lowercasing the directory fixes the problem, but we worry that updating will reintroduce it.

The slug from a download request is lowercase, but a package's slug may not be. I hacked together a workaround in the where method of AbstractRepository.

public function where( array $args ): array {
		$args       = $this->parse_args( $args );
		$matches    = [];
		$args_count = count( $args );

		foreach ( $this->all() as $item ) {
			$matched = 0;

			foreach ( $args as $key => $value ) {
				if ( $item[ $key ] && $value === $item[ $key ] ) {
					$matched++;
-                               }
+				} elseif ( 'slug' === $key ) {
+					if ( $item[ $key ] && strtolower( $item[ $key ] ) === $value ) {
+						$matched++;
+					}
+				}
+			}

			if ( $matched === $args_count ) {
				$matches[] = $item;
			}
		}

		return $matches;
	}

I'm not sure if this is an ideal solution, so I have not created a PR.

@bradyvercher
Copy link
Member

Thanks for the report @theschmocker. I looked into this a bit and it appears the problem occurs in the download route handler when sanitizing the slug. sanitize_key() converts characters to lowercase and causes the download to fail.

Let me know if the latest commit doesn't fix this for you.

@theschmocker
Copy link
Author

That fixed it. Thanks a lot!

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

No branches or pull requests

2 participants