Comment On N-Replace Zero-Test

Thomas Nordlander writes: "The Swedish Church of Scientology's scary personality test contains some pretty awesome JavaScript validation. Consider the ingenious way that they make sure they are dealing with numbers." [expand full text]
« PrevPage 1 | Page 2Next »

Re: N-Replace Zero-Test

2008-03-24 08:07 • by Shinhan (unregistered)
They are discriminating against people older than 99. I mean, babies are allowed, but old people are not? :(

Re: N-Replace Zero-Test

2008-03-24 08:12 • by Someone You Know
Notice that the ZIP function will succeed without checking the input if a hidden field on the form is set to "sverige" (Sweden), ignoring case.

Because, you know, Sweden is the only country that doesn't use a ZIP code.

Re: N-Replace Zero-Test

2008-03-24 08:14 • by jonny s. (unregistered)
185441 in reply to 185440
clearly, the swedish do not make mistakes when filling out online forms.

also: chocolate.

Re: N-Replace Zero-Test

2008-03-24 08:31 • by b.p. (unregistered)
But what if your 100+ years old and want to join?

Re: N-Replace Zero-Test

2008-03-24 08:34 • by Patrik (unregistered)
185444 in reply to 185440
Someone You Know:
Notice that the ZIP function will succeed without checking the input if a hidden field on the form is set to "sverige" (Sweden), ignoring case.

Because, you know, Sweden is the only country that doesn't use a ZIP code.


No, the other way round. They only validate Swedish ZIP codes, which actually makes sense.

The *real* WTF however is that they use regular expressions /1/../9/ instead of one /[1-9]/.

Re: N-Replace Zero-Test

2008-03-24 08:35 • by ParkinT
185445 in reply to 185443
b.p.:
But what if your 100+ years old and want to join?

"I would never want to belong to any group that would have someone like me for a member!" --Woody Allen

Re: N-Replace Zero-Test

2008-03-24 08:36 • by Volmarias
If all you have is a hammer, everything looks like a nail.

If all you have is scientology, all of your input looks like body thetans, and it needs to be purged.

Re: N-Replace Zero-Test

2008-03-24 08:40 • by Tim (unregistered)
No wonder so many websites will allow 000-000-0000 as a valid phone number.

Re: N-Replace Zero-Test

2008-03-24 08:41 • by Ed (unregistered)
185448 in reply to 185445
I think that was Groucho

Re: N-Replace Zero-Test

2008-03-24 08:43 • by KT (unregistered)
TRWTF is the <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br><br><br><br><br>
starting from line 456.

Re: N-Replace Zero-Test

2008-03-24 08:57 • by JD (unregistered)
When would s.substr(1,1) > "9" ever be true?

Re: N-Replace Zero-Test

2008-03-24 08:57 • by E (unregistered)
Couldn't they have at least taken all the replacement code out into another function if they were going to use it so much?

Re: N-Replace Zero-Test

2008-03-24 09:04 • by Shinhan (unregistered)
185452 in reply to 185444
Patrik:
Someone You Know:
Notice that the ZIP function will succeed without checking the input if a hidden field on the form is set to "sverige" (Sweden), ignoring case.

Because, you know, Sweden is the only country that doesn't use a ZIP code.


No, the other way round. They only validate Swedish ZIP codes, which actually makes sense.

The *real* WTF however is that they use regular expressions /1/../9/ instead of one /[1-9]/.


No, they wanted /^[0-9]{5}$/
/[1-9]/ makes sense only if 9999999 is a valid Zip Code.

Re: N-Replace Zero-Test

2008-03-24 09:09 • by pitchingchris
185454 in reply to 185443
b.p.:
But what if your 100+ years old and want to join?


Maybe they don't want a bunch of old people in their scientologist group. They wouldn't be missing anything.

Re: N-Replace Zero-Test

2008-03-24 09:10 • by John Doe (unregistered)
185455 in reply to 185439
Nope, babies, and kids under 10 are not allowed either. Two digits are required, but when age starts with a "0", it gets discarded as well.

Re: N-Replace Zero-Test

2008-03-24 09:26 • by A (unregistered)
Well damn. I filled out the whole ridiculously long 200 question questionnaire, and of course I didn't get anything for it, but they will call my number to tell me the results. The WTF is: only land lines, no cell phones.

Not that I gave any of my info of course, and if they send any emails, I hope webmaster@scientology.org will be happy :D

Re: N-Replace Zero-Test

2008-03-24 09:42 • by masklinn
185461 in reply to 185450
JD:
When would s.substr(1,1) > "9" ever be true?

For any character of charcode greater than 58.

So any character of this list:
:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~

Shinhan:
Patrik:
Someone You Know:
Notice that the ZIP function will succeed without checking the input if a hidden field on the form is set to "sverige" (Sweden), ignoring case.

Because, you know, Sweden is the only country that doesn't use a ZIP code.


No, the other way round. They only validate Swedish ZIP codes, which actually makes sense.

The *real* WTF however is that they use regular expressions /1/../9/ instead of one /[1-9]/.


No, they wanted /^[0-9]{5}$/
/[1-9]/ makes sense only if 9999999 is a valid Zip Code.

Also known as

/^\d{5}$/

Re: N-Replace Zero-Test

2008-03-24 09:56 • by MustBeUsersFault
You have to pay for more training in order to be enlightened and fully understand the hidden obfuscated powers of what seems to be silly javascript but is not.

And thetans.

Re: N-Replace Zero-Test

2008-03-24 10:04 • by Dunkelschub
The Real WTF is Scientology

Re: N-Replace Zero-Test

2008-03-24 10:48 • by savar
185483 in reply to 185461
masklinn:

Also known as

/^\d{5}$/


As always, the boggling part is: if they know how to match using /\d/, then why don't they know how to match using /^\d{5}$/ ?

Re: N-Replace Zero-Test

2008-03-24 10:49 • by codemonkey (unregistered)
185485 in reply to 185440
Entry:
if(trim(document.getElementById("M_land").value.toLowerCase()) != "sverige")
{ return(true); }

Someone You Know:
Notice that the ZIP function will succeed without checking the input if a hidden field on the form is set to "sverige" (Sweden), ignoring case.

Because, you know, Sweden is the only country that doesn't use a ZIP code.


Actually, it says val != "sverige" return true. Thus if the person is from Sweden, they require checking, otherwise they know what they're doing.

Entry:
if(s.substr(1,1) < "1" || s.substr(1,1) > "9")
return(false);

Also, last time I checked, substr(1,1) returned "".

Re: N-Replace Zero-Test

2008-03-24 11:12 • by KT (unregistered)
185493 in reply to 185483
savar:
masklinn:

Also known as

/^\d{5}$/


As always, the boggling part is: if they know how to match using /\d/, then why don't they know how to match using /^\d{5}$/ ?

At least they know \w.

/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/
(line 400)

Re: N-Replace Zero-Test

2008-03-24 11:12 • by JD (unregistered)
185494 in reply to 185461
masklinn:
JD:
When would s.substr(1,1) > "9" ever be true?

For any character of charcode greater than 58.

So any character of this list:
:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~


K, then since all they really seem to care about is whether a string of characters are numbers, can't they just loop through each string to see if each substring is between "1" and "9"? I mean, they do this anyway...

Re: N-Replace Zero-Test

2008-03-24 12:19 • by Tim (unregistered)
185515 in reply to 185446
Are non-zero numbers the equivalent of thetans? Maybe that's why these algorithms remove them. Just my 0 cents (thetans purged).

Re: N-Replace Zero-Test

2008-03-24 12:32 • by DeLos
185520 in reply to 185467
Dunkelschub:
The Real WTF is Scientology

You beat me to it!

Seriously though, does anyone else have the feeling that they are all laughing at us. Tom Cruise and John Travolta are sitting at dinner saying things like "I can't believe people are joining us!", "We can make people do ANYTHING because we are celebrities!" and "This is more fun than taking stands on politics!".

It really must be an elaborate joke. No one can really believe such things...


right?

Re: N-Replace Zero-Test

2008-03-24 12:54 • by Alcari (unregistered)
185527 in reply to 185494
JD:

K, then since all they really seem to care about is whether a string of characters are numbers, can't they just loop through each string to see if each substring is between "1" and "9"? I mean, they do this anyway...

Of course not. you can't just ADD something to this. It would destroy the artistic beauty of the the whole code.

shees.

Re: N-Replace Zero-Test

2008-03-24 12:57 • by zoips (unregistered)
185529 in reply to 185485
codemonkey:

Entry:
if(s.substr(1,1) < "1" || s.substr(1,1) > "9")
return(false);

Also, last time I checked, substr(1,1) returned "".


String.substr(index : Number, length : Number) : String

So no, substr(1, 1) returns a single character at index 1.

Re: N-Replace Zero-Test

2008-03-24 13:03 • by sheya (unregistered)
haha
must be one of the greediest companies still in existance :)

they dont have enough money to hire someone who UNDERSTANDS what they do

Re: N-Replace Zero-Test

2008-03-24 13:11 • by Aaron (unregistered)
The real WTF is that their checking won't allow anyone to be older than 99...

Re: N-Replace Zero-Test

2008-03-24 13:35 • by Bobble (unregistered)
It is not surprising that a Scientology site doesn't allow people younger than 10 or older than 99.

These groups must have been ruled out as revenue sources.

Re: N-Replace Zero-Test

2008-03-24 13:37 • by similis (unregistered)
Regexes are actually a conspiracy of the evil software conglomerates.

Re: N-Replace Zero-Test

2008-03-24 14:14 • by Tom Cruizer (unregistered)
185555 in reply to 185446
teh rofl

Re: N-Replace Zero-Test

2008-03-24 14:24 • by Anonymous (unregistered)
185558 in reply to 185446
Volmarias, you made me lol. Good show.

Re: N-Replace Zero-Test

2008-03-24 15:07 • by Minos
185566 in reply to 185520
DeLos:
Dunkelschub:
The Real WTF is Scientology

You beat me to it!

Seriously though, does anyone else have the feeling that they are all laughing at us. Tom Cruise and John Travolta are sitting at dinner saying things like "I can't believe people are joining us!", "We can make people do ANYTHING because we are celebrities!" and "This is more fun than taking stands on politics!".

It really must be an elaborate joke. No one can really believe such things...


right?


I have a theory about celebrities in Scientology. Whether they believe the myths of Scientology or not, their practice of "auditing" has the effect of training you to keep your cool when being harassed. That's an especially valuable skill for those constantly in the spotlight.

Re: N-Replace Zero-Test

2008-03-24 16:06 • by DeLos
185579 in reply to 185566
Minos:
DeLos:
Dunkelschub:
The Real WTF is Scientology

You beat me to it!

Seriously though, does anyone else have the feeling that they are all laughing at us. Tom Cruise and John Travolta are sitting at dinner saying things like "I can't believe people are joining us!", "We can make people do ANYTHING because we are celebrities!" and "This is more fun than taking stands on politics!".

It really must be an elaborate joke. No one can really believe such things...


right?


I have a theory about celebrities in Scientology. Whether they believe the myths of Scientology or not, their practice of "auditing" has the effect of training you to keep your cool when being harassed. That's an especially valuable skill for those constantly in the spotlight.


So instead of meditating they believe in aliens stuffing volcanoes?

Re: N-Replace Zero-Test

2008-03-24 16:47 • by jeff (unregistered)
awesome? no. ingenious? maybe. amateur? definitely.

all this nonsense:
s = s.replace(/1/g,"0");
s = s.replace(/2/g,"0");
s = s.replace(/3/g,"0");
s = s.replace(/4/g,"0");
s = s.replace(/5/g,"0");
s = s.replace(/6/g,"0");
s = s.replace(/7/g,"0");
s = s.replace(/8/g,"0");
s = s.replace(/9/g,"0");

can be replaced with:
s = s.replace(/\d/g,"0");

not that i'd do it that way in the first place... i guess the thetans made them do it.

Re: N-Replace Zero-Test

2008-03-24 16:50 • by psini (unregistered)
185586 in reply to 185445
ParkinT:
b.p.:
But what if your 100+ years old and want to join?

"I would never want to belong to any group that would have someone like me for a member!" --Woody Allen


er... I think it was a quote from Groucho Marx.

Re: N-Replace Zero-Test

2008-03-24 17:04 • by Anomynous (unregistered)
185588 in reply to 185439
Shinhan:
They are discriminating against people older than 99. I mean, babies are allowed, but old people are not? :(


In all seriousness, no, the Scientology organization is not interested in old people. They tend to discard the old and sick members once they are no longer of use to Scientology, and they focus on recruiting the young and rich.

Re: N-Replace Zero-Test

2008-03-24 17:05 • by Ron (unregistered)
Ok. If I ever saw ANYONE writing code at my company like this, I would fire them immediately.

Even if I wasn't their boss and I technically couldn't fire them, I would still fire them.

Re: N-Replace Zero-Test

2008-03-24 17:31 • by aaron (unregistered)
185594 in reply to 185454
only l.ron hubbard is allowed to be 100 yrs old or greater

Re: N-Replace Zero-Test

2008-03-24 18:25 • by Bing (unregistered)
185600 in reply to 185446
Oh my, they have good code! They must be evil!!!

Stop the anti-religion bullshit. Our time would be better spent on things that matter (like the wars, the economy, the election), rather than sensationalist bigotry crap.

Re: N-Replace Zero-Test

2008-03-24 19:00 • by Flash
185605 in reply to 185600
Bing:
Stop the anti-religion b***s***. Our time would be better spent on things that matter (like the wars, the economy, the election), rather than sensationalist bigotry crap.


It may be anti-religion BS, but it's not bigotry. People can't choose to be white, black, female, asian, or eskimo. So making fun of that is bigotry. People can choose what they believe (well, there are unfortunately exceptions in many places). If you have the freedom to believe, and you believe something stupid, you shouldn't be immune from reasoned ridicule.

Be careful! That's their IP!

2008-03-24 19:36 • by Imaginary Property (unregistered)
You should be careful with that code. It's probably copyrighted, patented and trademarked Religious Technology.

They don't trust "wog" technology made by non-Scientologists, so they have to do everything their own... unique ... way. I'm just waiting for them to send some kind of infringement notice and threaten to sue the site for 'injuring their reputation of being non-litigious' or something.

If possible, I suggest giving them Mandatory Fun Day as a compromise rather than going to court. It's the sort of thing a Scientologist might enjoy.

Re: N-Replace Zero-Test

2008-03-24 20:05 • by Gus (unregistered)
I guess people living past 99 breaks some kind of Hubbard law.

Re: N-Replace Zero-Test

2008-03-24 22:16 • by immibis (unregistered)
Where the hell is 'sverige'?

Re: N-Replace Zero-Test

2008-03-25 00:27 • by DeLos
185634 in reply to 185605
Flash:
Bing:
Stop the anti-religion b***s***. Our time would be better spent on things that matter (like the wars, the economy, the election), rather than sensationalist bigotry crap.


It may be anti-religion BS, but it's not bigotry. People can't choose to be white, black, female, asian, or eskimo. So making fun of that is bigotry. People can choose what they believe (well, there are unfortunately exceptions in many places). If you have the freedom to believe, and you believe something stupid, you shouldn't be immune from reasoned ridicule.


I'm offended you referred to scientology as being a religion. It's an insult to religion.

Re: N-Replace Zero-Test

2008-03-25 01:11 • by notme (unregistered)
185638 in reply to 185520
DeLos:
Dunkelschub:
The Real WTF is Scientology

You beat me to it!

Seriously though, does anyone else have the feeling that they are all laughing at us. Tom Cruise and John Travolta are sitting at dinner saying things like "I can't believe people are joining us!", "We can make people do ANYTHING because we are celebrities!" and "This is more fun than taking stands on politics!".

It really must be an elaborate joke. No one can really believe such things...


right?


Well, seen from an objective distance, many other world religions are not much less ridiculous than this one...

Re: N-Replace Zero-Test

2008-03-25 01:24 • by Anonymous (bahaha) (unregistered)
Proper input validation closed due to thetans. TRWTF is that anyone is surprised by this... after their sites got hacked, I mean DDOS'd, by teenage punks (before a more legal protest movement stepped in and replaced DoS'ing and blackfaxing), they called in consultants by the droves. Hearsay was that their systems were five years behind on security and defense (i.e. malware).

I guess before they pissed off the younger contingent of the Internet (i.e. 4chan) with that whole "yank the 'Tom Cruise laughs like a crazed slave and babbles' video" stunt, they just had old-timers picketing outside their buildings and talking smack about them on alt.religion.scientology.

Re: N-Replace Zero-Test

2008-03-25 04:54 • by Zing (unregistered)
185647 in reply to 185600
Bing:
Stop the anti-religion bullshit.

Christianity: $0.
Islam: $0.
Judaism: $0.
Hinduism: $0.
Buddhism: $0.

Scientology: $325,000.

Re: N-Replace Zero-Test

2008-03-25 05:15 • by SEMI-HYBRID code (unregistered)
185648 in reply to 185446
someone reads Raymond Chen's blog in here? =)
anyway, i like the method... it's similar to what i would do if i were too lazy to look for VB's IsNumeric function equivalent in JavaScript. (and to be honest, i really don't know the funcion name in JS O:-))
« PrevPage 1 | Page 2Next »

Add Comment