Bob On Development

Musings on the craft and business of software development









March 21, 2007

How Not to Evolve an API

Filed under: — bob @ 8:09 pm

I have a rather uneasy relationship with DotNetNuke, upon which my client’s membership-only web site is built. I just don’t care for DNN, but there is no one reason why. Just lots of little ones. As an example, last week I had a hair-pulling experience with DNN that has lessons for would-be framework developers.

Quick background for those not familiar with it: DNN is a content management system (CMS) for portal-type sites that has evolved over the last several years from the old IBuySpy sample application put together by Microsoft. That was one of the first ASP.NET proof-of-concept applications.

DNN has a concept of “skins” and “skin containers” for customizing look and feel. Normally you assign a skin to a DNN portal and that is the skin that’s used on all pages. However, there are times when you want to override this assigned skin for certain pages. This can be done in a number of ways, such as assigning a skin to a particular tab … er, page (pointlessly off-base terminology is another thing about DNN that I don’t care for).

For whatever reason the original developers of the system I work on chose to override skins programmatically by passing a SkinSrc querystring argument when calling up certain pages / controls / modules. You do this by appending a querystring argument to a URL similar to the following:

?SkinSrc=[G]Skins|_default|No Skin

This actually is URLEncoded and then you do your Response.Redirect() call or whatever, and the called URL will have the specified skin — in the above case a blank skin we used for a small modal dialog.

I won’t go into the wisdom of this little mini-language they cooked up for specifying skins … suffice it to say that the “[G]” is a token for which a path for global skins will be substituted by the system, and the pipes will end up being replaced with slashes to create a path, as you’ll see in a bit.

We were upgrading from DNN 3.0.13 to 3.3.7 … as a stepping-stone to ultimately getting back in sync with the current 4.x release and moving to ASP.NET 2.0. In testing the new version, I discovered that whenever we used one of these querystring skin overrides, the called page would fail, ending up at a URL that looked like this:

http://localhost/Default.aspx?tabid=591&error=illegal+characters+in+path

So I was obliged to dive into the open source of the core DNN code and figure out what was going on.

DNN routes all requests through default.aspx, and it turns out that the code-behind for that page handles the SkinSrc argument. QueryString(”SkinSrc”) gets passed to a core routine called QueryStringDecode() to get cleaned up. The old version of QueryStringDecode did pretty much what you’d expect: it URLDecodes the string and applies a couple of String.Replace() operations and returns the result. The net effect is that this:

%5bG%5dSkins%7c_default%7cNo+Skin

… becomes this:

[G]Skins|_default|No Skin

… and finally, this:

/Some/Global/Path/Skins/_default/No Skin

But in the new version of QueryStringDecode(), after doing the URLDecode(), a call is made to MapPath(), followed by some checks for cross-site scripting or attempts to access the parent directory. In other words, QueryStringDecode() has started acting like it expects paths rather than QueryString arguments. And the String.Replace() calls are simply gone.

It turns out that QueryStringDecode() is only called from a half-dozen places in the core, and is always passed a QueryString argument … but in all but two cases (including the one that was giving me fits) the QueryString argument was a path.

In essence, QueryStringDecode() was completely re-purposed and would now better be named PathVerify() or something along those lines. The URLDecode() should probably be removed and become the caller’s responsibility. In short, QueryStringDecode():

1. Has become confused as to its responsibilities — it should not assume it’s being passed a QueryString that needs URLDecoding if it’s going to deal with paths. The fact that all paths that are sent to it currently come out of QueryStrings is irrelevant.

2. Has departed so far from its original purpose that its name no longer applies

3. Has broken a legacy feature that, so far as I can find, has not been dropped or even deprecated. If it were dropped then the attempt to handle the SkinSrc argument should have been replaced by throwing a NotSupportedException.

Two one-line fixes solved the problem; instead of calling QueryStringDecode() for SkinSrc and a related ContainerSrc argument processed elsewhere, I just call HttpUtility.UrlDecode(whatever).Replace(”|”,”/”) and kaboom … it works fine. But, I still have to remember to change that in the core code with each DNN code update going forward. I’ll somehow find the time to check the 4.x source to see if it’s been fixed already and if not submit it for a future release … that’s the beauty of open source I guess. Hopefully it’ll be rolled into the core so I don’t have to make sure it stays in place on my end.

The moral of this story is that when you’re writing framework code you need to spend a lot of time thinking about your abstractions. Every bad decision you make will be enshrined in the system forever so it’s worth taking the extra effort to keep this stuff out up front as much as you can. That funky, arcane, overloaded argument convention for SkinSrc that I illustrated above was probably a rushed expediency that someone intended to re-visit before release, and never did. Worse, it apparently didn’t become part of the regression test suite and fell through the cracks entirely.

Now we are faced with a funky, arcane convention that’s broken, and documentation that calls QueryStringDecode() a security method through which all paths should be sent. Huh?! They almost might as well have assigned the method a random name.

Way to go, DNN core team!!

1 Comment »

  1. I found myself guilty of just this kind of responsibility creep a few weeks ago. Without an open source core team to give the stinkeye, I had only myself to blame for the misnamed function in front of me and spent some time considering how it got that bad.

    Comment by Brandon — March 22, 2007 @ 6:01 am

RSS feed for comments on this post. TrackBack URI

Leave a comment

Line and paragraph breaks automatic, e-mail address never displayed, HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

(required)

(required)


Powered by WordPress

Augmentin Avandamet Rhinocort Elavil Gasex Glucotrol XL Zelnorm Vermox Penis Growth Oil Nymphomax Adalat Prograf Geriforte Medithin Avalide Lariam Viagra Erexor Sarafem Confido Himplasia Arimidex Fosamax ActoPlus Met Mentat Cardizem Hytrin Cafergot Lasuna Mycelex G Hyzaar Buy Pro Erex Buy Lincocin Buy Viramune Buy Micardis Buy Nymphomax Buy Omnicef Buy Effexor Buy Accutane Buy Levothroid Buy Cialis Jelly Buy Femcare Buy Amoxil Buy Aleve Buy Cephalexin Buy Lotrisone Buy Acticin Buy Touch Up Kit Buy Metabo UltraMax Buy Orgasm Enhancer Buy Penis Growth Pack Buy Levlen Buy Styplon Buy Aceon Cheap Loxitane Cheap Differin Cheap Geriforte Cheap Dramamine Cheap Sinequan Cheap Hoodia Cheap Nolvadex Cheap Womens Intimacy Enhancer Cheap Medithin Cheap Female Sexual Tonic Cheap Purinethol Cheap Inderal Cheap Flomax Cheap Orgasm Enhancer Cheap Zimulti Cheap Erexor Cheap Avandamet Cheap Ceftin Cheap Buspar Cheap ZMA Power Cheap Wellbutrin SR Cheap Hoodia Gordonii HG p57 Cheap Singulair Cheap Avandia Cheap Soma Credit reporting system For low credit scores Commercial credit report Understanding credit score Credit report and Florida free credit report Chase credit card status 3 credit reporting agencies Beacon credit score Federal credit reporting act To credit reporting agencies Fix your credit report On line credit card applications Credit card offers Card credit reward travel Credit score formula Credit reports from all Credit free instant report Annual report credit Order credit reports Instant personal credit report Credit beacon score Juniper credit card application Free instant credit reports Airline credit card miles National credit card debt Vue prepaid credit card Credit card debt calculator Chase credit card complaints Is credit score Elan credit card services Balance transfer credit cards Fix my credit score Credit card machines uk Check credit report fix Credit scores of Credit report uk Balance transfers credit cards Average credit score Increasing credit scores Is my credit score Business credit report Redit card pros cons Acceptable credit score Credit card business industrial Credit reports for Fast credit score increase Credit card debt facts On line credit report Free credit reporting Order credit report Chase credit card application Credit reporting act litigation Credit report consumer Clean up credit report Affect your credit score Credit report annual Credit report online Chase redit card Getting a credit score Credit card debt history Credit score after bankruptcy Credit scores meaning Stop credit card offer Ranked credit card offers Mobile credit card processing Linkpoint credit card machine Credit card applications in Credit report disputes Student credit card debt Credit reporting columbia house Credit report service Cheap credit card uk 0 credit card offer Credit report agencies Credit report score understanding Credit cards 0 apr Anual credit report Application aspen card credit Credit score higher Credit card debt management Citibank credit card offers Great credit card offer Free business credit reports Introductory offer credit card Money bank credit card Interpreting credit scores Get credit reports Free credit report Credit card apply online Credit score services Interest credit card offers Credit card debt eliminate Equifax credit reporting Instant credit card offer Credit card consolidation loans Bad credit score Credit card application uk Credit rating score scale Free credit score Experian credit report Credit report.com Article credit card debt Consolidation credit card debt Credit card consolidation uk Stopping credit card offer Read my credit report Obtain a credit report Mint credit card deal Raise my credit score Experian credit report uk Reports credit cards Hurt my credit score Discover credit card offer Good credit rating score Of my credit report Repairing credit score Credit reporting codes Credit reports on Hsbc credit card Credit card application online Repair my credit report Apr credit card offers Credit card debt advice Credit scores by Compare credit card offers Prepaid credit card companies Credit card debt laws Unlimited credit reports Annual credit report request Get my credit report Aarp chase credit card Card consolidation credit debt Credit report companies About credit scores Card credit debt free Transunion credit score Free credit card report Application card citi credit Corporate credit card application Credit scores work Consumer credit reports Credit scores mortgage Freecredit report Credit reporting service Credit card application with Credit scores and Personal credit report canada Credit report identity theft Free anual credit report Improving credit score Credit score uk My annual credit report Landlord credit report Credit score rates With a credit score Credit report government The credit reporting Up credit reports Instant credit reports Fre credit report Visa card bad credit Fair credit reporting act Freecreditreports Credit report repair service Free online credit report To increase credit score Bank one credit card American credit card debt Credit fix repair report Stop credit card debt Instant credit reports uk Low credit scores Colorado free credit report Free transunion credit report Of credit score Company credit report Credit reports with Personal credit score repair Credit scores only Obtain free credit score Cic credit report Eliminate credit card debt Free yearly credit reports The best credit score Credit report canada Wamu secured credit card Uk credit card debt Hsbc rs credit card Check credit report equifax Providian credit card company Secured credit or card Canada credit report Online Femcare Lipitor Muscle Pain Hydrocodone No Prescription Online Furosemide Online Inderal Online Maximum Lipotropics Online Viagra Soft Tabs Online Rythmol SR Levitra Actress Online Avalide Online Lynoral Online Neurontin Online Cardura Online Valtrex Online Fosamax Online Ditropan Online Diamox Online MetaboSafe Online Anafranil Online Viramune Online Advair Diskus Online Pro Erex Online Medrol Online Levaquin Online Echinacea Online Betnovate Online Prevacid Online Male Enhancement Oil Online Vasodilan Online Glucotrol XL Lorazepam Online Cymbalta Online Endep Online Confido Online Keftab Online Depakote Lortab Online Prozac Online Methox 400 Online Anabol AMP Online Tribulus Lipitor Side Affects Online Bentyl Online Dramamine Online Geodon Xanax Addiction Vicodine Online Indocin Online Trimox Online Shoot Carisoprodol 350 Mg Vicodin Hp Online Colostrum 800 Tramadol Cod Zoloft Withdrawal Online Cardizem Online Hangover Helper Online Isoptin Online Nolvadex Online Amaryl Online Penisole Cialis Dosage Phentermine No Prescription Vicodin Lorazepam Overdose Online Liponexol Online Sumycin Online Evecare Online Differin Online Urispas Online Biaxin Online Antabuse Online Ventolin Online Styplon Carisoprodol Soma Online Sustiva Online Prinivil Online Casodex Online Vermox Diazepam Online Cafergot Online Detrol Online Melatonin Zoloft Side Effects Online Trandate Online Reglan Xanax Dosage Lorazepam Addiction Online Avapro Adipex P Didrex Diet Pills Cialis.Com Ultram Online Calcium Carbonate Online Zyloprim Online Desyrel Online Ponstel Viagra Side Effects Xanax Withdrawal Viagra Alternatives Online GABA (HGH Booster) Online Probalan Viagra Dosage Online Orgasm Enhancer Hydrocodone Apap Online Flexisyn Adipex No Prescription Xanax Abuse Viagra Online Tofranil Propecia Generic Phentermine Online Online Mentat Online Zanaflex Online Noxide Online Loxitane Online Lukol Levitra Drug Online Extendaquin Alprazolam No Prescription Online Hyzaar Online Pletal Online Zovirax Online Cialis Soft Tabs Online Relafen Online Quibron T Online Paxil Online Rocaltrol Online Coreg Online Mevacor Carisoprodol Online Maxaquin Online Tenormin Online Remeron Online Evegen Online Claritin Ativan Drug Online QuickBust Diazepam Dosage Tramadol Hcl Online Cystone Online Nymphomax