Exception in RuleUri constructor because of cyrillic type name.

Exception in RuleUri constructor because of cyrillic type name.

Old forum URL: forums.lhotka.net/forums/t/12049.aspx


sash_kr posted on Sunday, June 30, 2013

My application crashes with "DataPortal.Create failed (Invalid URI: The hostname could not be parsed.)" error.

After little debugging  I've found the source of the exception. Exception occurs in "public RuleUri(string typeName, string propertyName)" constructor. My typeName has non-latin name. It has cyrillic name. And encoded "uriString" looks like this:

"rule://CslaTest.Documents.-D0-94-D0-BE-D0-BA-D1-83-D0-BC-D0

 Uri is failed if char like '-' goes right after '.' (dot). If I will change above to this:

 "rule://CslaTest.Documents.D0-94-D0-BE-D0-BA-D1-83-D0-BC-D0

everythings is fine!

sash_kr replied on Thursday, July 04, 2013

Why no one react on this bug? Do you need a sample of namespace?

JonnyBee replied on Thursday, July 04, 2013

Hi,

Well, the question is,  is it a bug in .NET or in CSLA?

And are there other parts affected as well? 

For now - I have registered the issue in repository:
https://github.com/MarimerLLC/csla/issues/182  

sash_kr replied on Friday, July 05, 2013

 Well, I don't think that's a bug in Uri class. Uri has some format and that format don't like when char like '-' goes right after '.'.

For know I fix it like this:

instead:

    var uriString = "rule://" + hostName + "/" + EncodeString(propertyName);

use this:

    var uriString = "rule://" + hostName.Replace(".-", ".") + "/" + EncodeString(propertyName).Replace(".-", ".");

 

 But I would like, CSLA could handle this situation by itself.

 

P.S.

My class:

namespace CslaTest.Documents

{

    public abstract class Документ : BusinessBase<Документ>

JonnyBee replied on Friday, July 05, 2013

I'm quite sure this also applies to query parameters to the URI like additional fields or maybe even values added to the RuleName.

But I am suspection there may be other areas affected as well.

sash_kr replied on Friday, July 05, 2013

I'm new to CSLA. So, I don't fully understand what are you talking about. For now, my test project goes fine.

If you need some  cyrillic words for reproducing problem you can use this site for example:

http://learningrussian.net/vocabulary/russian-words/russian-months-and-seasons.php

Copyright (c) Marimer LLC