Skip to content

ElFinderLoader::encode($path) does not return any valid result #368

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

Closed
ofriedrich opened this issue Aug 4, 2019 · 1 comment
Closed

Comments

@ofriedrich
Copy link

Issue Type:

Please pick one and delete the rest:

  • Bug Report
Bundle Version:

Master

Summary:

We need to encode a path into a Elfinder specific hash. So we tried to use the FM\ElfinderBundle\Loader\ElFinderLoader:: encode($path) to get the hash for the current path. But the result was always empty.

Steps To Reproduce:

In a properly configured project create a controller like this:

    /**
     * @Route("/elfinder/path-to-hash/{instance}/{homeFolder}", methods={"GET"})
     * @param Request $request
     * @param string $instance
     * @param string $homeFolder
     * @return JsonResponse
     */
    public function pathToHash(Request $request, string $instance, string $homeFolder): JsonResponse
        $loader = $this->get('fm_elfinder.loader');
        $loader->initBridge($instance);
        if ($loader instanceof ElFinderLoader) {
            $loader->setSession(new ElFinderSession($this->get('session')));
        }
        $path = $request->query->get('path');
        $hash = $loader->encode($path);
        return new JsonResponse($hash);
}

Open your browser with the url containing the path in the query string.

Expected Results:

The response should contain the hash for the given path.

Actual Results:

The response always is an empty string.

Possible solution

$aPathEncoded[$hashId] = $volume->getPath($path);

            $aPathEncoded[$hashId] = $volume->getPath($path);

change into:

            $aPathEncoded[$hashId] = $volume->getHash($path);

The getPath-method converts a hash into a path. The getHash-method converts a path into a hash!

@helios-ag
Copy link
Owner

Changed in v10

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

No branches or pull requests

2 participants