Solved

Element is undefined in a Java object of type class coldfusion.filter.UrlScope.

Posted on 2009-05-13
2
958 Views
Last Modified: 2012-05-06
The body of code below thows the following error:

Element 10 is undefined in a Java object of type class coldfusion.filter.UrlScope.  
 
 
The error occurred in C:\nwmdev\apache\Apache2\htdocs\workspace\pdm\fusebox\login.cfm: line 51
 
49 : <cfloop collection="#url#" item="i">
50 :             <cfif NOT ListFindNoCase(ListIgnore, i, ",") and isAlphaNumeric(i)>
51 :                   <cfset uRow = listAppend(uRow,"#LCase(i)#/#LCase(URL[i])#","/")>
52 :             </cfif>
53 : </cfloop>
 
Note that the URL struct when dumped looks something like this::

struct
/WWW.SAFWE.COM WIDTH=900 HEIGHT=1100>:: [empty string]  
ERROR:: [empty string]  
FUSE:: login  
REDIRECT:: [empty string]  
REINIT:: false  
SUBMITTED:: &amp;gt;&amp;#x22;&amp;gt;&amp;lt;/title&amp;gt;&amp;lt;/iframe&amp;gt;&amp;lt;/script&amp;gt;&amp;lt;/form&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;lt;br&amp;gt;&amp;lt;iFraMe src=http:/  

Can anyone help me find the reason for this error.

// Returns true if the string only contains alpha numeric characters (empty string = true)
function isAlphaNumeric(txt) {
	return ValidString(txt,'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789');
}
 
// Returns true if the CheckString only contains characters passed in ValidString (empty string = true)
function ValidString(ChkString,ValidString) {
	for (i=1; i LTE Len(ChkString); i=i+1) {
		if (FindNoCase(Mid(ChkString,i,1), ValidString) eq 0) return false;
	}
	return true;
}
</cfscript>
 
 
<cfloop collection="#url#" item="i">
		<cfif NOT ListFindNoCase(ListIgnore, i, ",") and isAlphaNumeric(i)>
			<cfset uRow = listAppend(uRow,"#LCase(i)#/#LCase(URL[i])#","/")>
		</cfif>
</cfloop>

Open in new window

0
Comment
Question by:onaled777
2 Comments
 
LVL 52

Accepted Solution

by:
_agx_ earned 500 total points
ID: 24378816
It is probably a scoping clash.  In your function you are using a variable named "i" and also using that same variable name as your <cfloop> index. Since your function variables are not properly scoped, ValidString ends up overwriting or clashing with your cfloop index.

_Always_ var scope _all_ function local variables.  In other words, if a variable is only used in the function, place it in the VAR scope.  Also, you might consider using the newer cffunction syntax instead. It has some benefits over the old udf syntax.

// Returns true if the CheckString only contains characters passed in ValidString (empty string = true)
function ValidString(ChkString,ValidString) {
      var i = 0;
        for (i=1; i LTE Len(ChkString); i=i+1) {
                if (FindNoCase(Mid(ChkString,i,1), ValidString) eq 0) return false;
        }
        return true;
}
</cfscript>

Open in new window

0
 

Author Comment

by:onaled777
ID: 24379140
THANK YOU SO MUCH!
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Hi, Even though I have created this Tutorial on My personal Blog, Some people might not able to find my website, So here i am posting it again Today, from the topic it is very clear that i will be showing you here the very basic usage of how we …
This is an updated version of a post made on my blog over 3 years ago. It is unfortunately, still very relevant as we continue to see both SQLi (SQL injection) and XSS (cross site scripting) attacks hitting some of the most recognizable website and …
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question