Remove ChangeEnvironmentAction class and throw when env flag is set in mod_rewrite rule
This commit is contained in:
parent
58ef98b184
commit
e003594fd8
|
|
@ -30,4 +30,5 @@ project.lock.json
|
|||
.testPublish/
|
||||
.idea/
|
||||
.vscode/
|
||||
|
||||
*.nuget.props
|
||||
*.nuget.targets
|
||||
|
|
|
|||
|
|
@ -178,8 +178,7 @@ namespace Microsoft.AspNetCore.Rewrite.Internal.ApacheModRewrite
|
|||
|
||||
if (flags.GetValue(FlagType.Env, out flag))
|
||||
{
|
||||
// parse env
|
||||
_actions.Add(new ChangeEnvironmentAction(flag));
|
||||
throw new NotSupportedException(Resources.Error_ChangeEnvironmentNotSupported);
|
||||
}
|
||||
|
||||
if (flags.HasFlag(FlagType.Forbidden))
|
||||
|
|
|
|||
|
|
@ -1,22 +0,0 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
|
||||
namespace Microsoft.AspNetCore.Rewrite.Internal.UrlActions
|
||||
{
|
||||
public class ChangeEnvironmentAction : UrlAction
|
||||
{
|
||||
public ChangeEnvironmentAction(string env)
|
||||
{
|
||||
// TODO
|
||||
throw new NotImplementedException("Changing the environment is not implemented");
|
||||
}
|
||||
|
||||
public override void ApplyAction(RewriteContext context, MatchResults ruleMatch, MatchResults condMatch)
|
||||
{
|
||||
// Do stuff to modify the env
|
||||
throw new NotImplementedException("Changing the environment is not implemented");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -154,6 +154,22 @@ namespace Microsoft.AspNetCore.Rewrite
|
|||
return GetString("Error_IntegerMatch_FormatExceptionMessage");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Error adding a mod_rewrite rule. The change environment flag is not supported.
|
||||
/// </summary>
|
||||
internal static string Error_ChangeEnvironmentNotSupported
|
||||
{
|
||||
get { return GetString("Error_ChangeEnvironmentNotSupported"); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Error adding a mod_rewrite rule. The change environment flag is not supported.
|
||||
/// </summary>
|
||||
internal static string FormatError_ChangeEnvironmentNotSupported()
|
||||
{
|
||||
return GetString("Error_ChangeEnvironmentNotSupported");
|
||||
}
|
||||
|
||||
private static string GetString(string name, params string[] formatterNames)
|
||||
{
|
||||
var value = _resourceManager.GetString(name);
|
||||
|
|
|
|||
|
|
@ -144,4 +144,7 @@
|
|||
<data name="Error_IntegerMatch_FormatExceptionMessage" xml:space="preserve">
|
||||
<value>Syntax error for integers in comparison.</value>
|
||||
</data>
|
||||
<data name="Error_ChangeEnvironmentNotSupported" xml:space="preserve">
|
||||
<value>Error adding a mod_rewrite rule. The change environment flag is not supported.</value>
|
||||
</data>
|
||||
</root>
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using Microsoft.AspNetCore.Rewrite.Internal.ApacheModRewrite;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNetCore.Rewrite.Tests
|
||||
{
|
||||
public class RuleBuilderTest
|
||||
{
|
||||
[Fact]
|
||||
// see https://httpd.apache.org/docs/2.4/rewrite/advanced.html#setenvvars
|
||||
public void AddAction_Throws_ChangeEnvNotSupported()
|
||||
{
|
||||
var builder = new RuleBuilder();
|
||||
var flags = new Flags();
|
||||
flags.SetFlag(FlagType.Env, "rewritten:1");
|
||||
|
||||
var ex = Assert.Throws<NotSupportedException>(() => builder.AddAction(null, flags));
|
||||
Assert.Equal(Resources.Error_ChangeEnvironmentNotSupported, ex.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue