Freeway Changes my javascript! HELP! PLEASE!!!

I am running into a big problem. I have a program that generates code from the back end to create a form with javascript functions that check if your email is valid, etc.

When I create an html file in a text editor, the script works perfectly.

When I create a Markup Item in Freeway and preview, the script doesn’t work at all.

Here is what the correct, working line of code is coming from the back end:

ar mailPattern = /^([A-Za-z0-9_-.])+@([A-Za-z0-9_-.])+.([A-Za-z]{2,4})$/;

Here is what Freeway mangles it into:

ar mailPattern = /^([A-Za-z0-9_-.])+\@([A-Za-z0-9_\-\.])+.([A-Za-z]{2,4})$/;

I really need this script to work for me in Freeway. It’s very annoying and time consuming to have to preview the file, and go into a text editor to correct it so that it works. Any information will be greatly appreciated. Thanks in advance.


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

I’m not aware of Freeway escaping any regex like this, does the regex come from something you typed directly into a markup item, or does it come out of a content management system that stores the regex in a database?

But I’m not sure your regex is doing what you’d expect anyway. Inside a set of square brackets, a dash means a range from this to that. The only exception is when it’s the very first character inside the square brackets. Also, a dot must be escaped if you want to capture a literal dot, otherwise it means any character at all, except for a newline.

Finally, your “stuff after the @” portion is flat out never going to work because you are including the dot inside your first capture segment after the @ and then expecting the capture to stop when it encounters another dot (which you didn’t escape, so it’s really going to match any character at all), and it also doesn’t consider multiple-segment hostnames (subdomains like @pobox.upenn.edu) or multiple-segment domains, like .co.uk or similar.

I’d have a look for a better e-mail regex than this, unless you can rigidly control the range of e-mail addresses that are being entered in your system.

Walter


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

I just saw your message in Mail, which didn’t convert the character
entities into their actual characters. Here’s what I would have seen
on the Web if you had pasted the code as a code snippet (put a line
containing four tildes in a row before and after the code, like this):

Here is what the correct, working line of code is coming from the back  
end:

ar mailPattern = /^([A-Za-z0-9_-.])+@([A-Za-z0-9_-.])+.([A-Za-z] 
{2,4})$/;

Here is what Freeway mangles it into:

ar mailPattern = /^([A-Za-z0-9_- 
.])&#43 
;&#92 
;&#64 
;&#40 
;&#91 
;&#65 
;&#45 
;Za-z0-9_\-\.])+. 
([A-Za-z]{2,4})$/;

I think what is happening here is that Freeway’s built-in e-mail
obfuscator has decided that your regex is an actual e-mail address,
and is obfuscating it for you.

In the Document Setup, look for an option to “Encode e-mail addresses”
and turn it off. Your code should pass through unencoded, and your
regex should work. Apologies for lecturing you on regular expressions,
I can see that you did get the dash and dot properly escaped in your
pattern, but you still have the problems I noted in the second half of
the address, with the lack of support for subdomains or multi-part
domain names.

Walter

On Jul 31, 2010, at 12:09 PM, twb716 wrote:

Here is what the correct, working line of code is coming from the
back end:

ar mailPattern = /^([A-Za-z0-9_-.])+@([A-Za-z0-9_-.])+.([A-Za-
z]{2,4})$/;

Here is what Freeway mangles it into:

ar mailPattern = /^([A-Za-z0-9_-
.])&#43
;&#92
;&#64
;&#40
;&#91
;&#65
;&#45
;Za-z0-9_\-\.])+
.([A-Za-z]{2,4})$/;


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options