NancyFx/Nancy — Issue #459: Static content convention directories with Regex special characters in them always result in 404
Author: GraemeF
Created: 2012-01-05 20:25:50+00:00
State: open

I was trying to use the `StaticContentConventionBuilder` to set up a static content convention to serve up files from a directory that happened to have a `.` in its path (e.g. `C:\My.Stuff`), and found that I was always ending up with a 404 response.

In `BuildContentDelegate` it escapes the `contentPath` (which changes `.` into `\.`) before putting it in the `requestPath` which is then used to build `filePath`:

```
requestPath = Regex.Replace(requestPath, requestedPath, Regex.Escape(contentPath), RegexOptions.IgnoreCase);
```

Just after that, the unescaped `contentPath` is used to build `contentRootPath`, and then the condition compares the *unescaped* `contentPath` to the *escaped* `filePath`, which of course doesn't work as it should.

```
IsWithinContentFolder(contentRootPath, fileName)
```

Not sure what this is supposed to be doing so you'll forgive the lack of pull request, but it doesn't work the way it is :)