Show
Ignore:
Timestamp:
11/06/06 15:14:58 (2 years ago)
Author:
scorfield
Message:

Addresses #139 by adding a new attribute, relative=, to the <circuit> declaration in fusebox.xml and,
in strict mode, validating path= and throwing an exception if it is "/absolute/" rather than "relative/".
The default behavior is compatibile with Fusebox 5.0.0 and earlier releases.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • framework/trunk/fuseboxCircuit.cfc

    r264 r266  
    6363                <cfargument name="myFusebox" type="myFusebox" required="true"  
    6464                                        hint="I am the myFusebox data structure." /> 
     65                <cfargument name="relative" type="boolean" required="true"  
     66                                        hint="I indicate whether the path is relative or absolute (mapped)." /> 
    6567                 
    6668                <cfset variables.fuseboxApplication = arguments.fbApp /> 
    6769                <cfset variables.alias = arguments.alias /> 
     70                <cfset variables.relative = arguments.relative /> 
    6871 
    6972                <cfset variables.fuseboxLexicon = variables.fuseboxApplication.getFuseactionFactory().getBuiltinLexicon() /> 
     
    8184                </cfif> 
    8285                <cfset this.path = variables.relativePath /> 
    83                 <cfset variables.fullPath = variables.appPath & variables.relativePath /> 
     86                <!--- ticket 139: allow absolute path names and mappings: ---> 
     87                <cfif left(variables.relativePath,1) is "/"> 
     88                        <cfif variables.relative> 
     89                                <!--- unintentional absolute path? ---> 
     90                                <cfif variables.fuseboxApplication.strictMode> 
     91                                        <cfthrow type="fusebox.badGrammar.illegalPath" 
     92                                                        message="Circuit path is not relative" 
     93                                                        detail="The 'path' value '#variables.originalPath#' for circuit #getAlias()# specifies an absolute path. Did you forget to specify 'relative=""false""'?" /> 
     94                                </cfif> 
     95                                <cfset variables.fullPath = variables.appPath & variables.relativePath /> 
     96                        <cfelse> 
     97                                <!--- explicit absolute / mapped path: ---> 
     98                                <cfset variables.fullPath = expandPath(variables.relativePath) /> 
     99                        </cfif> 
     100                <cfelse> 
     101                        <cfif variables.relative> 
     102                                <cfset variables.fullPath = variables.appPath & variables.relativePath /> 
     103                        <cfelse> 
     104                                <cfthrow type="fusebox.badGrammar.illegalPath" 
     105                                                message="Circuit path is relative" 
     106                                                detail="The 'path' value '#variables.originalPath#' for circuit #getAlias()# should specify an absolute path when 'relative=""false""'." /> 
     107                        </cfif> 
     108                </cfif> 
    84109                <!--- remove pairs of directory/../ to form canonical path: ---> 
    85110                <cfloop condition="find('/../',variables.fullPath) gt 0"> 
    86111                        <cfset variables.fullPath = REreplace(variables.fullPath,"[^\.:/]*/\.\./","") /> 
    87112                </cfloop> 
     113                <!--- 
     114                        this was not correctly normalized prior to ticket 139 but it didn't really matter 
     115                        until absolute paths were allowed in that ticket: 
     116                ---> 
     117                <cfset variables.relativePath = variables.fuseboxApplication.relativePath(variables.appPath,variables.fullPath) /> 
    88118                <cfset this.rootPath = variables.fuseboxApplication.relativePath(variables.fullPath,variables.appPath) /> 
    89119 
     
    140170                                                <cfthrow type="fusebox.missingCircuitXML"  
    141171                                                                message="missing circuit.xml"  
    142                                                                 detail="The circuit xml file, #circuitFile#, for circuit #getAlias()# could not be found." 
     172                                                                detail="The circuit xml file, #circuitFile#, for circuit #getAlias()# could not be found in #variables.fullPath#." 
    143173                                                                extendedinfo="#cfcatch.detail#" /> 
    144174                                        </cfif> 
     
    284314         
    285315                <cfreturn variables.circuitFile /> 
     316         
     317        </cffunction> 
     318 
     319        <cffunction name="getOriginalPathIsRelative" returntype="string" access="public" output="false"  
     320                                hint="I return true if this circuit's declaration used a relative path."> 
     321         
     322                <cfreturn variables.relative /> 
    286323         
    287324        </cffunction>