qpscanner icon indicating copy to clipboard operation
qpscanner copied to clipboard

Error message when using UNC path

Open cherdt opened this issue 10 years ago • 1 comments

When I try to scan a directory on a UNC path, e.g. //server/share/path, QueryParam Scanner drops the first slash and throws an error:

Specified path [/server/share/path] cannot be accessed or does not exist.

I traced the issue to the following line in cfcs/settings.cfc, in the normalizePath method: <cfset var Result = Arguments.Path.replaceAll('[\/]+','/') />

(I removed the plus sign in the regex to get this to work in my scenario, but that may or may not allow other problematic paths.)

cherdt avatar Aug 01 '14 19:08 cherdt

Well the simple solution is to have the code on the server itself. It'll run faster there too. (Unless you have gigabit networking and slow hard drives or something.)

Or you can swap the function for this:

<cffunction name="normalizePath" returntype="String" output=false access="private">
    <cfargument name="Path" type="String" required_ />

    <cfset var Prefix = 'file:////' />

    <cfset Arguments.Path = Arguments.Path.replaceFirst('^\\\\',Prefix) />

    <cfif Arguments.Path.startsWith(Prefix)>
        <cfset var Result = new cfregex('[\\/]+').replace(Arguments.Path,'/',len(Prefix)) />
    <cfelse>
        <cfset var Result = Arguments.Path.replaceAll('[\\/]+','/') />
    </cfif>

    <cfif len(Result) AND Result.endsWith('/') AND NOT Result.endsWith(':/') >
        <cfset Result = Left(Result,len(Result)-1) />
    </cfif>

    <cfreturn Result />
</cffunction>

boughtonp avatar Aug 02 '14 17:08 boughtonp