• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

CFPARAM Problem

Guest
Jan 02, 2008 Jan 02, 2008

Copy link to clipboard

Copied

Hi All,

Does anyone know how to get POSIX style character classes working in a CFPARAM wiith type="regex"? E.G.]

<cfparam name="frustrate" type="regex" pattern="[[:print:]]" default="">

This throws an error when I pass in any value.

. Invalid parameter type.The value does not match the regular expression pattern provided. The specific sequence of files included or processed is: ......

The only regular expression classes I can get working are the usual ASCII ones ([a-z] etc) but I need to validate UTF-8 characters as well. I've searched the Adobe forums, some CF blogs and of course I RTFM but I can't see any way of doing this without writing out the character codes longhand which is not only a maintenance issue but would then require far more testing just to ensure there are no ommissions. If anyone can help, it would be appreciated.
TOPICS
Advanced techniques

Views

401

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Deleted User
Jan 02, 2008 Jan 02, 2008
Thanks Adam and Paul for responding.

The manual does indicate that only JavaScript compatible patterns will work in CFPARAM and that does indicate using the longhand Unicode syntax which doesn't suck a bit, it SUCKS A LOT!!!!

The only way I have found to overcome the issue is to wrap my cfparam in a try/catch, use the basic JS compatible pattern eg \w , and when it throws an error do a negative test using the POSIX style class. Then if that fails I know I have a character that is unacceptable ...

Votes

Translate

Translate
LEGEND ,
Jan 02, 2008 Jan 02, 2008

Copy link to clipboard

Copied

Fusionneer wrote:
> Does anyone know how to get POSIX style character classes working in a CFPARAM
> wiith type="regex"? E.G.]

:print: is a valid char class for cf regex & seems to work as expected w/the cf
regex functions. might be something about cfparam's regex. i'm no regex expert
but is there any difference between POSIX regex & "JavaScript regular
expression" (which the docs say cfparam uses)?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 02, 2008 Jan 02, 2008

Copy link to clipboard

Copied

> of course I RTFM

Looking @ this:
http://livedocs.adobe.com/coldfusion/8/Tags_p-q_01.html

The regex pattern needs to be a JavaScript compatible pattern.

JavaScript regexes don't support Unicode, beyond \uhhhh, from what I'm
finding.

That sux a bit, dunnit?

--
Adam

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jan 02, 2008 Jan 02, 2008

Copy link to clipboard

Copied

Thanks Adam and Paul for responding.

The manual does indicate that only JavaScript compatible patterns will work in CFPARAM and that does indicate using the longhand Unicode syntax which doesn't suck a bit, it SUCKS A LOT!!!!

The only way I have found to overcome the issue is to wrap my cfparam in a try/catch, use the basic JS compatible pattern eg \w , and when it throws an error do a negative test using the POSIX style class. Then if that fails I know I have a character that is unacceptable and so I can rethrow the original error. EG:

<cftry>
<cfparam name="FORM.houseNo" type="regex" pattern="[-a-zA-z0-9_#]+|\s{1}" default="32">
<cfcatch type="any">
<cfif ReFindNoCase("[^[:print:]]+",FORM.houseNo,1,"true") >
<!--- Fail here - doesn't match ASCII Or UNICODE --->
<cfrethrow>
</cfif>
</cfcatch>
</cftry>

Of course I then need to wrap all my individual try/catch cfparam blocks with another try / catch block just so I can pick up the rethrows.

This is so ugly I am thinking of removing my cfparam tags altogether and just going with the regular expression checks.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 02, 2008 Jan 02, 2008

Copy link to clipboard

Copied

> This is so ugly I am thinking of removing my cfparam tags altogether and just
> going with the regular expression checks.

That's what I was going to suggest.

if (structKeyExists(form, "houseNo") and reFind(etc))

Remember to anchor the regex to both beginning and end of string, otherwise
you could find embedded matches, not just complete matches.

--
Adam

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 02, 2008 Jan 02, 2008

Copy link to clipboard

Copied

LATEST
Fusionneer wrote:
> The manual does indicate that only JavaScript compatible patterns will work in
> CFPARAM and that does indicate using the longhand Unicode syntax which doesn't
> suck a bit, it SUCKS A LOT!!!!

http://www.adobe.com/cfusion/mmform/index.cfm?name=wishform&product=12&6213=6

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation