| « Prev | Page 1 | Page 2 | Page 3 | Next » |
Re: RegExp From Down Under
2009-10-05 09:05
•
by
John
(unregistered)
|
|
NOT!
|
|
var comment = new RegExp(/^(W|w)(T|t)(F|f)|(W|w)\.(T|t)\.(F|f)\.$/);
|
|
You call that a regular expression? This is a regular expression!
|
|
That's not a regex that's a string!
|
|
Looks like someone wanted to use RegEx but didn't know what it's for.
|
|
But Regular Expressions work so much better! I'm sure the boss said something like "Gidday mate! Why don't you just use a regex to filter out Australians!"
|
|
Well, that's different a different way to do it.
|
|
Fail. No multithreading.
|
|
RegEx.... Austrailian for String
|
|
Fail for no XML
|
|
I like how they tell customer to visit the exact same site if they enter australia as a country. A clueless user could enter some kind of infinite loop and try to book forever.
|
|
Forgot to check for "OZ".
|
|
But what about testing for "Orstrylya"?
|
No, I don't know what it means either. |
|
There are at least 2 WTFs here. First, that what they've written could have been written a lot more succinctly (the regex should be marked case-insensitive, and even for a developer unaware of that option it could be written much more simply than that....). Second, what the code actually does is probably a bad idea in the first place. (A drop-down box for the country might work better than trying to parse entered country names, with either a prompt disallowing Australia and New Zealand, or just not putting them there in the first place; but even then, what they're trying to accomplish is probably not a good idea, especially as a drop-down box has usability problems of its own.) Other potential WTFs here (as in, almost certainly a WTF, but there isn't enough information in the article to tell): if that validation code isn't duplicated server-side, or if the server-side validation code has the same, or a different, bug; and is there a good reason to not just process the info as if it had been entered in the other website (or auto-redirect to the other website, or just not have two websites at all)?
|
|
Dang no check for a dingo.
captcha: vulputate - A masturbating vulture? trwtf: posting STILL isn't fixed Alex quit writing columns for Dev Disasters and fix this board! |
|
Well I guess they never heard about the /i qualifier.... ;-)
Besides, how many ways are there to spell Australia using 'funny' characters as substitutes to fool this check (or just plain spelling errors)???? Yours yazeran Plabn: To go to Mars one day with a hammer. |
|
Since when is New Zealand not outside Australia?
Must be pretty much hated by the Kiwis, that site. |
|
"Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems."
|
|
And what if the bloke enters "shenanigans"?
|
Re: RegExp From Down Under
2009-10-05 09:44
•
by
Kiss me I'm Polish
|
There are 10 types of people - those who understand binary, and those who have regular sex. Now please can we be done with quoting famous people without giving them proper credit? Pretty please. |
|
That regex should go straight to the poolroom.
Obviously the developer is an ideas man. (Tell him he's dreaming). http://www.youtube.com/watch?v=TM-GVRvsZrA |
"Regular expressions are neither" I am sure someone will explain this as well. |
|
Why use a regex? It's so inefficient for finding what's effectively a known quantity. They're not searching for any string, they're searching for a particular one. Sure, there's some permutations with capitalization, but those can be checked for with some hard coded values. As long as you put them in the right order, they index search will be faster than the initialization of the regex engine.
if (inputbox.value == "australia") alert ("You cannot be in australia"); else if (inputbox.value == "australiA") alert ("You cannot be in australiA"); else if (inputbox.value == "australIa") alert ("You cannot be in australIa"); else if (inputbox.value == "australIA") alert ("You cannot be in australIA"); else if (inputbox.value == "austraLia") alert ("You cannot be in austraLiA"); etc. Nothing a bit of copy'n'paste (or Excel manipulating) can't produce in less time than mucking with a regex could. |
Re: RegExp From Down Under
2009-10-05 09:51
•
by
Anon
(unregistered)
|
Thanks for clarifying that, "Not JWZ". |
|
Balderdash!
var validator = new RegExp( /^(A|a)(U|u)(S|s)(T|t)(R|r)(A|a)(L|l)(I|i)(A|a) |(N|n)(E|e)(W|w)(Z|z)(E|e)(A|a)(L|l)(A|a)(N|n)(D|d) |(N|n)(E|e)(W|w) (Z|z)(E|e)(A|a)(L|l)(A|a)(N|n)(D|d)$/); should be taken out as a global variable in case someone tries to repeatedly make a booking from Australia! |
Re: RegExp From Down Under
2009-10-05 09:56
•
by
Anon
(unregistered)
|
Sounds legit. |
Re: RegExp From Down Under
2009-10-05 10:02
•
by
@Deprecated
(unregistered)
|
He's going about this all wrong. Instead, the code should test for every other country in the world, and let those pass. That way you can't submit with Austarlia or NewZaeland |
Re: RegExp From Down Under
2009-10-05 10:18
•
by
Edward Royce
(unregistered)
|
Hmmmm. It needs XPath! |
Re: RegExp From Down Under
2009-10-05 10:24
•
by
Beaker
(unregistered)
|
Good idea, but the array of strings that could be other countries might be a bit too big to test in a for-switch. captcha is "plaga": Spanish for plague. |
Umm...No? Did you read the article? |
|
Ohh, now I get the WTF. They did this:
When they could've done this:
|
|
TRWTF is all the people using pseudo Australian slang.
|
Re: RegExp From Down Under
2009-10-05 10:40
•
by
!?
(unregistered)
|
Argh! Would you people please stop making bizarre associations between anything latin or latin-like with something sexual. If you don't know, search for it. You are on the \b\w*(ing|ed)?\b internet. |
|
They should have just reported their international site to Australia's government censorship board, and let the ISPs do the work.
|
|
...what I want to say?
|
|
This is the reason why devs should be banned from using JavaScript for anything other than field validation, and even then the validation should also be done server-side.
This regexp doesn't qualify as "validation". Let's see how it gets bypassed by "New Zealand"! :) Addendum (2009-10-05 11:11): Meh, this thing ate the extra spaces ... I meant "New[space][space]Zealand"!!! |
Re: RegExp From Down Under
2009-10-05 10:45
•
by
Bim Job
(unregistered)
|
You're just annoyed because Jamie has a /^(P|p)(O|o)(L|l)(I|i)(S|s)(H|h) |(P|p)(O|o)(L|l)(S|s)(K|k)(I|i)(E|e)$/) surname, aren't you? |
Re: RegExp From Down Under
2009-10-05 11:00
•
by
@Deprecated
(unregistered)
|
Sorry, I thought we were offering up ridiculous ideas here today. |
Re: RegExp From Down Under
2009-10-05 11:06
•
by
!?
(unregistered)
|
And it might be necessary to check for all the misspellings the country names may have in english and every other language, including esperanto. |
|
Why do a stach of ifs?
Convert the string to al lowercase, than do a single if. |
Re: RegExp From Down Under
2009-10-05 11:14
•
by
Anon
(unregistered)
|
Simple, we put them in a database and then get retrieve them as XML via a web service and use that to dynamically generate a giant if/else if construct to check for countries that are allowed to pass. If more countries are created later, you can simply update the database and everything is taken care of. |
Re: RegExp From Down Under
2009-10-05 11:16
•
by
Anon
(unregistered)
|
<sarcasm>Genius! I can't imagine why nobody else has suggested that yet!</sarcasm> |
I think "Australia" has the same name/spelling in most languages. "Nueva Zelanda" does break that regexp though. Allowing textfields for country could bring on interesting results... wonder if someone would put "Sealand" or "Lizbekistan" there... |
|
Alternate solution:
ask the Powers Below to add the site to the Great Australian Firewall list of blocked sites... |
Meh, depends on if they get better deals that way. Speaking as a Canadian, I can tell you that on a website that provides or sells services or products, 99% of the time I'd rather Canada be included as part of the States. (Hulu, Amazon, and on, and on). |
Re: RegExp From Down Under
2009-10-05 11:20
•
by
Alan
(unregistered)
|
No? Because the error tells them to visit *.com.au and that is the AU equivalent of *.com or *.us (similar to *.co.uk for commercial websites in the UK). Someone made a typo in the actual article, tho, because it's missing the required ".com" in the ".au" domain. I hate it when people see a mistake in the article, get all worked up on it and then don't double-check before posting. |
| « Prev | Page 1 | Page 2 | Page 3 | Next » |