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

URLs are parsed incorrectly if they don't end with / or /something #1840

Closed
rgavilan opened this issue Jun 16, 2022 · 1 comment
Closed

URLs are parsed incorrectly if they don't end with / or /something #1840

rgavilan opened this issue Jun 16, 2022 · 1 comment

Comments

@rgavilan
Copy link

rgavilan commented Jun 16, 2022

sysPass Version
3.2.6

Describe the bug
After updating to version 3.2.6 we have detected that some URLs are displayed incorrectly on the search screen. For instance, if we set the URL https://www.google.com in the account, we can see on the search screen the value https%3A%2F%2Fwww.google.com and the link is https://syspass-url/https%3A%2F%2Fwww.google.com

I suppose the problem is related with this function:

    /**
     * @param  string  $url
     *
     * @return string
     */
    public static function getSafeUrl(string $url): string
    {
        if (preg_match('#^((?:https?|ftp|ssh|rdp)://[\w._-]+/)(.*)#', $url, $urlParts)
            && count($urlParts) === 3) {
            return $urlParts[1].urlencode($urlParts[2]);
        }

        return urlencode($url);
    }

The regexp expects the url has 3 parts, and if it doesn't finish with / or /something, it doesn't match.

To Reproduce
Steps to reproduce the behavior:

  1. Set an URL in an account without context path, for instance https://www.google.com
  2. Goto search screen and locate the account
  3. Look at the URL and the link
  4. See error

Expected behavior
URLs should be parsed correctly regardless of whether they end with / or not

Screenshots

image

nuxsmin added a commit that referenced this issue Jun 18, 2022
Thanks to @rgavilan for the feedback!
Closes #1840.

Signed-off-by: Rubén D <nuxsmin@syspass.org>
@rgavilan
Copy link
Author

Thank you for the solution, but the problem is still here although is not exactly the same. Now, when an URL doesn't end with / or /somethig the system adds /https in search screen.

image

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

1 participant