jakubgarfield / Bonobo-Git-Server

Bonobo Git Server for Windows is a web application you can install on your IIS and easily manage and connect to your git repositories. Go to homepage for release and more info.
http://bonobogitserver.com
MIT License
1.81k stars 603 forks source link

Can't edit repository after "disallow special characters for repository name pull request" #194

Closed alexkuznetsov closed 9 years ago

alexkuznetsov commented 9 years ago

Hello! I repeat my comment from #159.

After #159 we can't edit several ours repos. They have a dots in names - name like namespace in C# (Blah.Blah2.Blah3 or Blah.BlahBlah).

What about to use something like that:

var repositoryName = repositoryName.Trim('.');

It will be removed dots from start and end of repository name.

ghost commented 9 years ago

What exception do you have? Where does the error occur? In the browser or Git-Client? I made this PR and i just disallow special characters if you create a new repository. The existing repos shouldn't be affected.

I will check this, too. But it could need some time.. To remove the dot in the end is a possible solution, too. Intention with the limit to a-Z,_ and - was that the Browser/URL could have problems, if you use other characters.

Hint: The PR is from October. So it has been a long time in the Git-Server. Have you checked out the version with the PR mentioned and tested this special version? Perhaps some other things could affect the integration with the git-client.

alexkuznetsov commented 9 years ago

Our error: screenshot_1

It happens in browser, then i try to save repository. screenshot_3

In second screenshot you can see hidden field with validation.

I understand that my proposal is not a fix for #142, so if i can help you with something - just tell me. If refactoring for regex is complicated, may be we can replace it to something like that?

And in remote validator action we can:

  1. Check for dots;
  2. Check for forbidden (special) characters
ghost commented 9 years ago

Ah okay, i think i got the problem. I thought first, its in the git-client you use. But this error occurs if you update your repo during the website.

I will update that Regex-Statement so that dot is allowed, but not in the end. I think i can do a PR in a few days (perhaps today evening).

alexkuznetsov commented 9 years ago

Good, thank you very much for your help!

ghost commented 9 years ago

@alexkuznetsov: Can you test the new Regex please? In fixed it in my fork (https://github.com/mbedded/Bonobo-Git-Server/tree/RegexFix). You have to download the fork and compile the sources. If you can't do that (no Visual Studio or something) i can try to make the compiled code available to you on another way. Please compile and check if the fixed regex solves your problem.

I fixed the Regex so you can write the following characters: a-z/A-Z 0-9 . - _ I added the expression: "[^.]$" Thats checks if the string doesn't end with a dot. If it ends with a dot, there will be the typical error-message.

For me it was possible to create repos like "abc.def", "abc", "a..........b", "aaa.bbb.ccc.dd".

If this fix work, i will adjust the text for the error messages. Then i will create a PR. Thank you and sorry for the inconvenience.

alexkuznetsov commented 9 years ago

@mbedded yes, sure. I will test it in LinqPad for all our repo names with dots and will write here about results.

I think, i can test your fork tommorow in office, approximately at 02:00-03:00 UTC.

alexkuznetsov commented 9 years ago

All names are passed. My test:

void Main()
{
    var names = new [] { 
        "Blah.Blah.Blh.Blaaah",
        ".Blah.Blah.Blh.Blaaah"
    };

    foreach(var name in names)
    {
        Test(name);
    }
}

void Test(string name)
{
    TestOriginal(name);
    TestModified(name);
}

void TestOriginal(string name)
{
    var reg = new System.Text.RegularExpressions.Regex("([a-zA-Z0-9-_.])+([^.])$");
    var results = reg.IsMatch(name);
    results.Dump(name + ": Original Regex");
}

void TestModified(string name)
{
    var reg = new System.Text.RegularExpressions.Regex("^([^.])+([a-zA-Z0-9-_.])+([^.])$");
    var results = reg.IsMatch(name);
    results.Dump(name + ": Modified Regex");
}

In the modified regex more strict check. And a results in screenshot: screenshot_4

ghost commented 9 years ago

The regex i have written doesn't check for a dot in the beginning of the string it has the following format: "([a-zA-Z0-9-_.])+([^.])$" I think we should let it be so easy, because the main reason for that feature was that a user had a problem, if the name of a git-repository ended with a dot.

But if this works i will update the messages and make a PR.

alexkuznetsov commented 9 years ago

I think we should let it be so easy, because the main reason for that feature was that a user had a problem, if the name of a git-repository ended with a dot.

I think let it be original regex - ([a-zA-Z0-9-_.])+([^.])$. As i write before it work for me.

ghost commented 9 years ago

I made a PR with the updated regex. I opened a "thread" to ask other users, if they have some special characters. The format could affect other people, too and i want to prevent an issue like you had.