Changeset 266

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.

Location:
framework/trunk
Files:
5 modified

Legend:

Unmodified
Added
Removed
  • framework/trunk/fusebox.dtd

    r133 r266  
    1313        path CDATA #REQUIRED 
    1414        parent CDATA #IMPLIED 
     15        relative (true | false) "true" 
    1516> 
    1617<!-- 
  • framework/trunk/fuseboxApplication.cfc

    r265 r266  
    9393                                        hint="I am the myFusebox data structure." /> 
    9494                 
    95                 <!--- fixed ticket 99 again ---> 
     95                <!--- fixed ticket 139 ---> 
    9696                <cfset var myVersion = "5.0.1.#REReplace('$LastChangedRevision$','[^0-9]','','all')#" /> 
    9797 
     
    635635                <cfset var alias = "" /> 
    636636                <cfset var parent = "" /> 
     637                <cfset var relative = true /> 
    637638                <cfset var nAttrs = 0 /> 
    638639                 
     
    658659                                <cfset nAttrs = 2 /> 
    659660                        </cfif> 
     661                        <cfif structKeyExists(children[i].xmlAttributes,"relative")> 
     662                                <!--- TODO: check it is boolean ---> 
     663                                <cfset relative = children[i].xmlAttributes.relative /> 
     664                                <cfset nAttrs = nAttrs + 1 /> 
     665                        <cfelse> 
     666                                <cfset parent = "" /> 
     667                        </cfif> 
    660668                        <cfif this.strictMode and nAttrs neq structCount(children[i].xmlAttributes)> 
    661669                                <cfthrow type="fusebox.badGrammar.unexpectedAttributes" 
     
    668676                        <cfif structKeyExists(previousCircuits,alias) and 
    669677                                        children[i].xmlAttributes.path is previousCircuits[alias].getOriginalPath() and 
    670                                         parent is previousCircuits[alias].parent> 
     678                                        parent is previousCircuits[alias].parent and 
     679                                        relative eq previousCircuits[alias].getOriginalPathIsRelative()> 
    671680                                <!--- old circuit, we can just reload it ---> 
    672681                                <cfset this.circuits[alias] = previousCircuits[alias].reload(arguments.myFusebox) /> 
     
    675684                                <cfset this.circuits[alias] = 
    676685                                                createObject("component","fuseboxCircuit") 
    677                                                         .init(this,alias,children[i].xmlAttributes.path,parent,arguments.myFusebox) /> 
     686                                                        .init(this,alias,children[i].xmlAttributes.path,parent,arguments.myFusebox,relative) /> 
    678687                        </cfif> 
    679688                </cfloop> 
  • 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> 
  • framework/trunk/myFusebox.cfc

    r265 r266  
    5151<cfcomponent hint="I provide the per-request myFusebox data structure and some convenience methods."> 
    5252        <cfscript> 
    53         // fixed ticket 99 for fusebox files 
     53        // fixed ticket 139 
    5454        this.version.runtime     = "5.0.1.#REReplace('$LastChangedRevision$','[^0-9]','','all')#"; 
    5555           
  • framework/trunk/skeleton/fusebox.xml.cfm

    r203 r266  
    77<fusebox> 
    88        <circuits> 
     9                <!-- illustrates defaults for parent ("") and relative ("true") --> 
    910                <circuit alias="m" path="model/" parent="" /> 
    1011                <circuit alias="v" path="views/" parent="" /> 
    11                 <circuit alias="app" path="controller/" parent="" /> 
     12                <circuit alias="app" path="controller/" relative="true" /> 
    1213        </circuits> 
    1314 
     
    2122                <!-- change this to something more secure: --> 
    2223                <parameter name="password" value="skeleton" /> 
     24                <parameter name="strictMode" value="true" /> 
    2325                <!-- 
    2426                        These are all default values that can be overridden: