- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
Because the process calls for a user to upload a .txt file! Yes, they COULD cram the data into another extension, but they'd be doing something wrong (Not covered ybt he procedure they should be following).
How many major errorrs have we all seen, heck how many are on this SITE, trhat follow this pattern:
User X does someting inherently wrong, like submitting the entire parts .xls "database" to the upload routine.
The upload routine was written to be "clever", and parses the .xls file, even though it shouldn't.
The resulting FUBAR costs $$$ and a WTF is submitted.
Moral: The hardware is dumb, and so are the users. Just because YOU can concieve of a bizzare scenario where you would want the program to handle anyt extension type, doesn't mean that implementing it would make the program "Better" or "More robust". Why not just create a genera purpose loader progam (Call it RUNPROG, to keep things simple) to export the .xls to a .txt, call the uploader, write the FORTRAN compiler to tape backup....
Admin
+1
Admin
Admin
That's Excel's idiosyncrasy.
Admin
mv Free_Bird.mp3 importdata.txt
Now run that app, and watch how it does a rematch of the "Free Bird Database" article we had some time ago!
Admin
Duh! Who cares about the extension?
He should have used a data generator to generate all 293,847,637,468,794,376 terabytes of valid inputs and checked to make sure the content was okay. Noobs.
Admin
Comment of the month?
Admin
Agreed. I'd hazard a guess that even in Kristof's specific case, the "WTF" code would lead to a much better user experience. In general, I'm sure it would. Neither approach is needed though, or really even useful. The correct approach obviously would have been proper data validation.
The real WTF is that that is what Kristof thought the "WTF" code was there for. He failed to glean the actual purpose the code: not to allow only .txt, as he incorrectly assumed, but rather to prevent a few obviously wrong extensions.
Admin
captcha: iusto. iusto be a programmer a long while ago.
Admin
Admin
If you think that having a .txt extension says anything about the data itself, than the hardware is dumb, the users are dumb, and so are you.
Admin
fileName.ToString();
... why is he converting a string to a string?
and Kristof's solution could be better written as
thereby allowing for several different extensions and excluding all others
Admin
This is why:
because if the extension is wrong, chances are the rest of the data is too, so don't bother trying.Admin
Ah, the old whitelist vs. blacklist philosophy. Kristof's colleague must have worked in the antivirus industry prior to this.
Admin
Stupidification!
Admin
Admin
Wow...just, wow. Sure, it's true there's a common misnomer with CSVs, frequently they are actually CSSVs instead of true CSVs, but Character-Spaced-Value?
Admin
Care to explain your logic? I agree with Frits here.
Admin
This is why coding jobs are easy to outsource, too many "big brains" solving for stupid nonsense that nobody cares about (except them).
The business partner agrees to upload a .txt file, so of course you check the extension before you process it.
After it passes that check, you will verify the layout of the file in whichever way makes the most sense.
There's more wtf worthy answers in this thread than there was wtf'ness in the article.
Admin
Hmmmm.
The Real WTF is not using XML!
...
Sorry I had to do that. Couldn't resist.
Admin
CSV stands for "Comma-separated values" and in a conformant CSV file the delimiter should always be a comma. If you want to embed commas or line breaks into a field's content you can put it into double quotes.
For a more official version of the story: http://tools.ietf.org/rfc/rfc4180.txt
Captcha: iusto. Not fair!
Admin
But if it is a requirement, then it's the requirements that are the WTF for needlessly requiring a certain filename pattern. Either way, it's a requirement/implementation detail that gains nothing and is more work. You make it sound like you need to be clever or overthinking the problem to simply NOT do something.
Admin
Hmmm... You mean like overthinking by responding 20 times trying to argue or prove a point that you're correct and everyone else is somehow absolutely wrong? You know that old saying about how everyone has an opinion...
Admin
I think it is cute how, instead of refuting his very good point, you feel the need to resort to personal attacks. YOU are the one that is simply spewing worthless drivel.
Admin
Admin
Admin
+1
Admin
Don't forget to submit all your outsourced code to TDWTF when you start having problems :)
Admin
When you see something like s.ToString() (where s is a string!) - it's a lost cause (the programmer, not the program).
Admin
Whoosh... Strike one!
Admin
Admin
WIN
Admin
Did you have a point, or do you just like seeing your words magically appear on the shiny glass box?
Admin
Assuming that it was stated in the requirements that the files had to have a .txt extension, the whole file extension debate is moot.
Admin
Admin
Admin
Nothing to see here. Move on. Next WTF, please.
Admin
And assuming everyone involved was a narwhale then the entire debate is also moot, because who really gives a damn what narwhales do?
The fact is that both of these assumptions are stupid to make, being completely baseless.
Admin
Does the OP work for a law firm? It's a basic tenet of justice that every csv file is innocent until proven guilty..
CAPTCHA: incassum - 'in vain', which is kind of appropriate to the solution I guess.
Admin
But if the original coder did that kind of a job with the file name, how bad is the content validation ?
Admin
Admin
#!/usr/bin/perl -w
Convert Excel spreadsheet to PDF
works only in DOS or Windows
FOSS by Joe
my $old = $ARGV[0]; $new = $old; $new =~ s/.xlsx?$/.pdf/; rename $old, $new;
Admin
... and I thought that tab was a character, stupid me.
Admin
TRWTF is using upload to feed data to the system. Certainly this data is available somewhere else, and the application could have read from there.
Admin
.regex isn't even a real extension type. Geez.
Admin
If you want a box containing square things, it's a good idea to make the hole in the lid square so that people know what to put in it. Any preschooler can tell you that. ;)
But agreed that checking the file extension shouldn't be any more than a userland filter, otherwise you'll undoubtedly run afoul of those users who worked out how to change file extensions and really really want to get their excel sheet into your app.
Admin
I hope you're joking. If so, it wasn't a very good joke.
Admin
Kristof should have told him that adding .doc and .pdf wasn't quite good enough, and that he needed to add all the extensions listed on FileInfo.com.
Admin
Admin
Being evolved from a system developed on old and currently ridiculously obsolete technology is not retarded.
In this particular case, the extension originally was metadata. In directory listing, it was listed in it's own column, just like for example modification time.
What perhaps is retarded is, that at some point this metadata got merged into file name. So we have both software and users that like to pretend it's still metadata, and then we have retards who call this retarded without suggesting any working alternative.
The fact is, there won't be an alternative in our lifetime, because there just are too many legacy files, and too many legacy users.