Skip to content

Conversation

@yhabteab
Copy link
Member

resolves #186

@yhabteab yhabteab force-pushed the bugfix/fix-backslashes-in-url-path-causes-error-186 branch from 992df30 to a5d8e86 Compare January 14, 2021 10:30
@yhabteab yhabteab requested a review from LordHepipud January 14, 2021 10:33
@yhabteab yhabteab self-assigned this Jan 14, 2021
@yhabteab yhabteab added the Bug There is an issue present label Jan 14, 2021
@yhabteab yhabteab added this to the v1.4.0 milestone Jan 14, 2021
Copy link
Collaborator

@LordHepipud LordHepipud left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello,

we will not do it this way. This will break the possibility to use web urls as it will enforce local paths instead of allowing local, web and network share paths.

Please use Test-Path to check if the path is a local path and use \ for splitting and otherewise /

@yhabteab yhabteab force-pushed the bugfix/fix-backslashes-in-url-path-causes-error-186 branch from a5d8e86 to 561291c Compare January 14, 2021 13:17
@yhabteab
Copy link
Member Author

I don't think that all local paths can be specified with backslash but also with a normal slash as @Nathaniel-Donahue described in the issue, so it would be better to just check if the url contains slash or backslash.

@yhabteab yhabteab requested a review from LordHepipud January 14, 2021 13:21
@LordHepipud
Copy link
Collaborator

LordHepipud commented Jan 14, 2021

It doesn't matter because the "fix" you provide will enforce a local path, because with your check testing for $CustomBinaryUrl will always result in $CustomBinaryUrl = $TRUE

It doesnt matter if you are using

C:\users\dummy\service.zip

or

https://example.com/binary.zip

Because you are always setting $CustomBinaryUrl = $TRUE by checking if $FrameworkServiceUrl is empty or not, you are not checking if it is a local path or a web path (both should work).

And therefor you are always enforcing this part:

if ($CustomBinaryUrl) {
       $ZipArchive = Join-Path -Path $TmpDirectory -ChildPath ($FrameworkServiceUrl.Split('\')[-1]);
}

With the latest update, you check in addition for bachslashes in the path with

if ($CustomBinaryUrl -and ($FrameworkServiceUrl.Contains('\'))) {

The proper solution would be this block:

if (Test-Path $FrameworkServiceUrl) {
    $ZipArchive = Join-Path -Path $TmpDirectory -ChildPath ($FrameworkServiceUrl.Replace('/', '\').Split('\')[-1]);
} else {
    $ZipArchive = Join-Path -Path $TmpDirectory -ChildPath ($FrameworkServiceUrl.Split('/')[-1]);
}

The rest of the updated code can be removed.

Because it doesn't matter on how you specify the local path:

icinga> Test-Path C:\Users\dummy\
True
icinga> Test-Path C:/Users/dummy/
True
icinga> Test-Path '\\network_fileshare\Icinga'
True
icinga> Test-Path '//network_fileshare/Icinga'
True
icinga> Test-Path 'www.icinga.com'
False

@yhabteab yhabteab force-pushed the bugfix/fix-backslashes-in-url-path-causes-error-186 branch 3 times, most recently from 37ed48c to df80f86 Compare January 26, 2021 14:45
Copy link
Collaborator

@LordHepipud LordHepipud left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LFTM

@yhabteab yhabteab force-pushed the bugfix/fix-backslashes-in-url-path-causes-error-186 branch from df80f86 to 76e8203 Compare January 26, 2021 14:51
@yhabteab yhabteab force-pushed the bugfix/fix-backslashes-in-url-path-causes-error-186 branch from 76e8203 to 0fdb3b1 Compare January 26, 2021 15:02
@LordHepipud LordHepipud merged commit b614b5a into master Jan 26, 2021
@LordHepipud LordHepipud modified the milestones: v1.4.0, v1.3.1 Feb 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug There is an issue present

Projects

None yet

3 participants