> I can't confirm this. I used this code and it worked fine. I think you
> have an error elsewhere.
>
> <cfset fieldValue = "foo">
> <cfscript>
> http = Left(fieldValue, 7) EQ "http://";;
> https = Left(fieldValue, 8) EQ "https://";;
> ftp = Left(fieldValue, 6) EQ "ftp://";;
> gopher = Left(fieldValue, 9) EQ "gopher://";;
> telnet = Left(fieldValue, 9) EQ "telnet://";;
> nntp = Left(fieldValue, 7) EQ "nntp://";;
> wais = Left(fieldValue, 7) EQ "wais://";;
> </cfscript>

The full tag code is at the bottom. It works with form input.

I think the error might be something to do with the long testing statement
after the variables for the protocols are set, but it is definitely
something to do with the variable names. I consistently get the
"coldfusion.runtime.CGIscope" error when the var names are as above; when I
change them so they aren't the same as the protocols, works fine.

Also, the error only occurs when 'fieldValue' actually contains a URL of
some sort...

- Gyrus

~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- [EMAIL PROTECTED]
work: http://www.tengai.co.uk
play: http://www.norlonto.net
- PGP key available
~~~~~~~~~~~~~~~~~~~~~~~~~~~~

<!---

FILENAME
act_formValidURL.cfm

AUTHOR
[EMAIL PROTECTED]

RESPONSIBILITIES
I make sure the specified fields contain valid URLs.

VARIABLES
-> attributes.fields
 List of form fields to be checked
<- request.formValid
<- request.problemFields

--->

<!--- Initialise variables --->
<cfparam name="attributes.fields" default="">
<cfparam name="request.problemFields" default="">

<cfscript>
 for (pos=1; pos LTE ListLen(attributes.fields); pos=pos+1) {
  field = ListGetAt(attributes.fields, pos);
  fieldValue = Trim(Evaluate("form."&field));
  space = Find(" ", fieldValue);
  period = Find(".", fieldValue);
  http = Left(fieldValue, 7) EQ "http://";;
  https = Left(fieldValue, 8) EQ "https://";;
  ftp = Left(fieldValue, 6) EQ "ftp://";;
  gopher = Left(fieldValue, 9) EQ "gopher://";;
  telnet = Left(fieldValue, 9) EQ "telnet://";;
  nntp = Left(fieldValue, 7) EQ "nntp://";;
  wais = Left(fieldValue, 7) EQ "wais://";;
  if (
    (NOT period) OR
    (space) OR
    ((NOT http) AND (NOT https) AND (NOT ftp) AND (NOT gopher) AND (NOT
telnet) AND (NOT nntp) AND (NOT wais))
   ) {
   request.formValid = FALSE;
   if (NOT ListFind(request.problemFields, field)) {
    request.problemFields = ListAppend(request.problemFields, field);
   }
  }
 }
</cfscript>


______________________________________________________________________
Signup for the Fusion Authority news alert and keep up with the latest news in 
ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to