Friday, October 22, 2010

All your prefix are belong to us now

@YaronNaveh

UPDATE: seems like I'm late to the party in a few years...

This one really surprised me. I have built a utility which saves WSDL files locally. Now a WSDL can reside in exotic locations such as "http://server/service/?q=wsdl" or "http://service/...[900 chars]..." which do not imply a natural candidate for the local file name (the latter also violated the 256 characters path limit). But I wouldn't want the utility to use opaque names such as "1.wsdl" either. So I use this code snippet to generate a meaningful name from a url, which is cool. Usually. The other day a user complained that the utility does not work with his wsdl which resides here:

http://server.com/con.service?wsdl

Seems pretty straight forward. Until you do this:

1. open notepad.exe
2. try to save as "con.txt"

this yields the below:

con.txt
This file name is reserved for use by Windows.
Choose another name and try again.

And if you try to rename a file directly from explorer you face:

The specified device name is invalid.

But it all makes sense when you read the rules:

Do not use the following reserved device names for the name of a file:

CON, PRN, AUX, NUL, COM1, COM2, COM3, COM4, COM5, COM6, COM7, COM8, COM9, LPT1, LPT2, LPT3, LPT4, LPT5, LPT6, LPT7, LPT8, and LPT9

Applications that automatically save files from url's must take this into account.

@YaronNaveh

What's next? get this blog rss updates or register for mail updates!

0 comments: