Changeset 166

Show
Ignore:
Timestamp:
05/28/06 17:11:45 (3 years ago)
Author:
scorfield
Message:

Addresses #41 by validating the circuit tag and the fuseaction tags in the circuit.xml file.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • fusebox5/fuseboxCircuit.cfc

    r161 r166  
    349349                <cfset var aLex = "" /> 
    350350                <cfset var ns = "" /> 
     351                <cfset var strict = getApplication().strictMode /> 
    351352                 
    352353                <!--- pass 1: pull out any namespace declarations ---> 
     
    381382                                                        detail="The lexicon prefix '#ns#' was found on a custom attribute in the <circuit> tag of Circuit #getAlias()# but no such lexicon namespace has been declared." /> 
    382383                                </cfif> 
     384                        <cfelseif strict and listFind("access,permissions",attr) eq 0> 
     385                                <cfthrow type="fusebox.badGrammar.unexpectedAttributes" 
     386                                                message="Unexpected attributes" 
     387                                                detail="Unexpected attributes were found in the 'circuit' tag of the '#getAlias()#' circuit.xml file." /> 
    383388                        </cfif> 
    384389                </cfloop> 
     
    442447                <cfset var ns = "" /> 
    443448                <cfset var customAttribs = 0 /> 
     449                <!--- default fuseaction access to circuit access ---> 
     450                <cfset var access = this.access /> 
     451                <cfset var permissions = "" /> 
     452                <cfset var strict = getApplication().strictMode /> 
    444453                 
    445454                <cfset this.fuseactions = structNew() /> 
     
    447456                <cfloop from="1" to="#n#" index="i"> 
    448457                        <cfset attribs = children[i].xmlAttributes /> 
     458                         
     459                        <cfif not structKeyExists(attribs,"name")> 
     460                                <cfthrow type="fusebox.badGrammar.requiredAttributeMissing" 
     461                                                message="Required attribute is missing" 
     462                                                detail="The attribute 'name' is required, for a 'fuseaction' declaration in circuit #getAlias()#." /> 
     463                        </cfif> 
    449464 
    450465                        <!--- scan for custom attributes ---> 
    451466                        <cfset customAttribs = structNew() /> 
    452467                        <cfloop collection="#attribs#" item="attr"> 
     468 
    453469                                <cfif listLen(attr,":") eq 2> 
    454470                                        <!--- looks like a custom attribute: ---> 
     
    461477                                                                detail="The lexicon prefix '#ns#' was found on a custom attribute in the Fuseaction #attribs.name# in Circuit #getAlias()# but no such lexicon namespace has been declared." /> 
    462478                                        </cfif> 
     479 
     480                                <cfelseif attr is "name"> 
     481                                        <cfif structKeyExists(this.fuseactions,attribs.name)> 
     482                                                <cfthrow type="fusebox.overloadedFuseaction"  
     483                                                                message="overloaded Fuseaction"  
     484                                                                detail="You referenced a fuseaction, #attribs.name#, which has been defined multiple times in circuit #getAlias()#. Fusebox does not allow overloaded methods." /> 
     485                                        </cfif> 
     486 
     487                                <cfelseif attr is "access"> 
     488                                        <cfset access = attributes.access /> 
     489                                        <cfif listFind("private,internal,public",access) eq 0> 
     490                                                <cfthrow type="fusebox.badGrammar.illegalAccess" 
     491                                                                message="Fuseaction access illegal" 
     492                                                                detail="The 'access' value '#access#' is illegal on Fuseaction #attribs.name# in Circuit #getAlias()#. 'private', 'internal' or 'public' are the only legal values." /> 
     493                                        </cfif> 
     494 
     495                                <cfelseif attr is "permissions"> 
     496                                        <cfset permissions = attribs.permissions /> 
     497 
     498                                <cfelseif strict> 
     499                                        <cfthrow type="fusebox.badGrammar.unexpectedAttributes" 
     500                                                        message="Unexpected attributes" 
     501                                                        detail="Unexpected attribute '#attr#' found on Fuseaction #attribs.name# in Circuit #getAlias()#." /> 
    463502                                </cfif> 
    464503                        </cfloop> 
    465504 
    466                         <cfif structKeyExists(attribs,"access")> 
    467                                 <cfif listFind("private,internal,public",attribs.access) eq 0> 
    468                                         <cfthrow type="fusebox.badGrammar.illegalAccess" 
    469                                                         message="Fuseaction access illegal" 
    470                                                         detail="The 'access' value '#attribs.access#' is illegal on Fuseaction #attribs.name# in Circuit #getAlias()#. 'private', 'internal' or 'public' are the only legal values." /> 
    471                                 </cfif> 
    472                         <cfelse> 
    473                                 <!--- default fuseaction access to circuit access ---> 
    474                                 <cfset attribs.access = this.access /> 
    475                         </cfif> 
    476                         <cfif structKeyExists(this.fuseactions,attribs.name)> 
    477                                 <cfthrow type="fusebox.overloadedFuseaction"  
    478                                                 message="overloaded Fuseaction"  
    479                                                 detail="You referenced a fuseaction, #attribs.name#, which has been defined multiple times in circuit #getAlias()#. Fusebox does not allow overloaded methods." /> 
    480                         </cfif> 
    481505                        <cfset this.fuseactions[attribs.name] = 
    482506                                        createObject("component","fuseboxAction") 
    483                                                 .init(this,attribs.name,attribs.access,children[i].xmlChildren,false,customAttribs) /> 
    484  
    485                         <!--- FB41 compatibility for security plugins ---> 
    486                         <cfif structKeyExists(attribs,"permissions")> 
    487                                 <cfset this.fuseactions[attribs.name].permissions = attribs.permissions /> 
    488                         <cfelse> 
    489                                 <cfset this.fuseactions[attribs.name].permissions = "" /> 
    490                         </cfif> 
     507                                                .init(this,attribs.name,access,children[i].xmlChildren,false,customAttribs) /> 
     508                        <!--- FB41 security plugin compatibility: ---> 
     509                        <cfset this.fuseactions[attribs.name].permissions = permissions /> 
    491510                </cfloop> 
    492511