Problem with spaces in target path

Nov 12, 2009 at 9:23 AM

I'm having trouble redirecting to a path with spaces in it. I was wondering whether I'm doing something wrong or if it could be bug perhaps.

I've created a cleaned-up test project, with the following files:

ManagedFusion.Rewriter.txt

RewriteEngine on

# Logging
RewriteLogLevel 9
RewriteLog "D:\Documents and Settings\ErikJan\Mijn documenten\Visual Studio 2008\Projects\RewriteWebAppTest1\RewriteWebAppTest1\App_Data\rewrite.log"

RewriteBase /

# any file that exists just return it
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^(.*)$ $1 [L]

RewriteRule ^/cursus/gebruikers/running_demos/      /running_demos/ [NC,L]

web.config

<?xml version="1.0"?>
<configuration>
	<configSections>
		<section name="managedFusion.rewriter" type="ManagedFusion.Rewriter.Configuration.ManagedFusionRewriterSectionGroup" requirePermission="false"/>
	</configSections>
	<managedFusion.rewriter xmlns="http://managedfusion.com/xsd/managedFusion/rewriter">
		<rules engine="Apache">
			<apache defaultFileName="ManagedFusion.Rewriter.txt"/>
		</rules>
		<rewriter rebaseClientPath="false" allowXRewriteUrlHeader="true" allowIis7TransferRequest="false">
			<proxy useAsyncProxy="true"/>
		</rewriter>
	</managedFusion.rewriter>
	<appSettings/>
	<connectionStrings/>
	<system.web>
		<compilation debug="true">
		</compilation>
		<authentication mode="Windows"/>
		<httpModules>
			<add name="RewriterModule" type="ManagedFusion.Rewriter.RewriterModule, ManagedFusion.Rewriter"/>
		</httpModules>
	</system.web>
	<system.webServer>
		<modules>
			<add name="RewriterModule" type="ManagedFusion.Rewriter.RewriterModule, ManagedFusion.Rewriter"/>
		</modules>
		<validation validateIntegratedModeConfiguration="false"/>
	</system.webServer>
</configuration>

In the root I've created the directory /running_demos/ with the executable file "Navigeren in de Online Zelfstudie.EXE" in it. 

When I request the url /cursus/gebruikers/running_demos/Navigeren%20in%20de%20Online%20Zelfstudie.EXE  it should redirect to /running_demos/Navigeren%20in%20de%20Online%20Zelfstudie.EXE

However, I'm getting a 404 error (sorry, Dutch Windows):

Serverfout in toepassing /.

De bron kan niet worden gevonden.

Beschrijving: HTTP 404. Mogelijk is de door u gezochte bron (of een afhankelijkheid daarvan) verwijderd of tijdelijk niet beschikbaar, of is de naam ervan veranderd. Controleer de spelling van de volgende URL.

Aangevraagde URL: /running_demos/Navigeren%20in%20de%20Online%20Zelfstudie.EXE


Versiegegevens: Microsoft .NET Framework Versie:2.0.50727.3082; ASP.NET Versie:2.0.50727.400

 

As you see the requested URL is /running_demos/Navigeren%20in%20de%20Online%20Zelfstudie.EXE  and this is the correct URL. If I just copy-paste this in the address bar and hit Enter, the executable file is downloading just fine.

I don't see anything wrong in the rewrite.log either:

Rule Processing: RewriteLog: D:\Documents and Settings\ErikJan\Mijn documenten\Visual Studio 2008\Projects\RewriteWebAppTest1\RewriteWebAppTest1\App_Data\rewrite.log
Rule Processing: RewriteBase: 
Rule Processing: Comment: # any file that exists just return it
Rule Processing: RewriteCond: %{REQUEST_FILENAME} -f []
Rule Processing: RewriteRule: ^(.*)$ $1 [L]
Rule Processing: RewriteRule: ^/cursus/gebruikers/running_demos/ /running_demos/ [NC,L]
Rule Processing: Managed Fusion Rewriter Version: 3.0.8.17706
**********************************************************************************
Rewrite: Input: http://localhost:2080/default.aspx?
Rule 0: Input: /default.aspx?
Rule 0: Rule Pattern Matched
Condition 0: Input: D:\Documents and Settings\ErikJan\Mijn documenten\Visual Studio 2008\Projects\RewriteWebAppTest1\RewriteWebAppTest1\default.aspx
Rule 0: Output: /default.aspx?
Rewrite: Output: http://localhost:2080/default.aspx?
**********************************************************************************
**********************************************************************************
Rewrite: Input: http://localhost:2080/cursus/gebruikers/running_demos/Navigeren in de Online Zelfstudie.EXE
Rule 0: Input: /cursus/gebruikers/running_demos/Navigeren%20in%20de%20Online%20Zelfstudie.EXE
Rule 0: Rule Pattern Matched
Condition 0: Input: D:\Documents and Settings\ErikJan\Mijn documenten\Visual Studio 2008\Projects\RewriteWebAppTest1\RewriteWebAppTest1\cursus\gebruikers\running_demos\Navigeren in de Online Zelfstudie.EXE
Rule 1: Input: /cursus/gebruikers/running_demos/Navigeren%20in%20de%20Online%20Zelfstudie.EXE
Rule 1: Rule Pattern Matched
Rule 1: Output: /running_demos/Navigeren%20in%20de%20Online%20Zelfstudie.EXE
Rewrite: Output: http://localhost:2080/running_demos/Navigeren in de Online Zelfstudie.EXE
**********************************************************************************

I've tried adding [NE] to the RewriteRule and also tried adding /(.*)$ to the source and /${escape:$1} to the target, but none of them work.

The webapp is running inside the ASP.NET Development Server started from the VS IDE.

Am I missing something in my RewriteRule or is it something else?

Erik Jan

Coordinator
Nov 12, 2009 at 11:17 AM

The only thing I can see is that when it actually gets rewritten it doesn't use the escaped spaces.  

http://localhost:2080/running_demos/Navigeren in de Online Zelfstudie.EXE

Do you think that could be the problem?  Also I don't think I have hooked up the NE flag, so that this why that doesn't work.  But it looks like the file name is getting unescaped when it is actually rewriting the output.  I will take a look at this, it should be relatively easy to reproduce.

Nov 12, 2009 at 3:05 PM

I don't think that could be the problem, but I could be wrong.
Because when I request the file directly (and the download window comes up), the logfile also contains the url with unescaped spaces, so that doesn't seem to be of influence. But perhaps that doesn't say much.

 

**********************************************************************************
Rewrite: Input: http://localhost:2080/running_demos/Navigeren in de Online Zelfstudie.EXE
Rule 0: Input: /running_demos/Navigeren%20in%20de%20Online%20Zelfstudie.EXE
Rewrite: Output: http://localhost:2080/running_demos/Navigeren in de Online Zelfstudie.EXE
**********************************************************************************

If you could take a look at this, I would be much obliged.

 

Coordinator
Nov 12, 2009 at 4:56 PM

Hmmm....  You are right, and there wouldn't be any difference between the two, at least how they are processed.   I will take a look at it and let you know.

Coordinator
Nov 16, 2009 at 12:26 PM

Just to let you know I am still working on this.

Coordinator
Nov 17, 2009 at 1:56 PM

Found the issue, it is because the URL is being escaped.  I need to do further research to make sure this will not have further effects on the rewriter if I change this.

Nov 17, 2009 at 2:05 PM

OK great, thank you. I understand.