Quantcast
Channel: Adobe Community : All Content - ColdFusion
Viewing all articles
Browse latest Browse all 5979

Empty User Agent string checking with RegEx fails

$
0
0

Why does this not work for the User Agent empty string?

<cfif REFindNoCase("^$", CGI.HTTP_USER_AGENT)>

   <cfoutput>

      "#CGI.HTTP_USER_AGENT#"

   </cfoutput>

</cfif>

 

For obvious reasons this works as an alternative.

<cfif ! len(CGI.HTTP_USER_AGENT)>

   <cfoutput>

      "#CGI.HTTP_USER_AGENT#"

   </cfoutput>

</cfif>

 

However, I'm not really interested in a workaround but the reason why the firt RegEx approach fails.

 

Testing conducted with FF Add-On "User Agent Switcher" I'm able to impersonate a browser that is void of a UA.

 

Other info:

Adobe ColdFusion 9.0.1

Server 2008 R2 64 bit

Testing code from within application.cfm


Viewing all articles
Browse latest Browse all 5979

Trending Articles