Skip to content

Commit 471a61a

Browse files
committed
fix: potential double encoding of paths
Signed-off-by: Vincent Biret <vibiret@microsoft.com>
1 parent 4c757e1 commit 471a61a

File tree

1 file changed

+3
-12
lines changed

1 file changed

+3
-12
lines changed

src/Microsoft.OpenApi/Services/OpenApiWalker.cs

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1297,15 +1297,6 @@ internal void Walk(IOpenApiElement element)
12971297
}
12981298
}
12991299

1300-
private static string ReplaceSlashes(string value)
1301-
{
1302-
#if NET8_0_OR_GREATER
1303-
return value.Replace("/", "~1", StringComparison.Ordinal);
1304-
#else
1305-
return value.Replace("/", "~1");
1306-
#endif
1307-
}
1308-
13091300
/// <summary>
13101301
/// Adds a segment to the context path to enable pointing to the current location in the document
13111302
/// </summary>
@@ -1315,7 +1306,7 @@ private static string ReplaceSlashes(string value)
13151306
/// <param name="walk">An action that walks objects within the context.</param>
13161307
private void WalkItem<T>(string context, T state, Action<OpenApiWalker, T> walk)
13171308
{
1318-
_visitor.Enter(ReplaceSlashes(context));
1309+
_visitor.Enter(context);
13191310
walk(this, state);
13201311
_visitor.Exit();
13211312
}
@@ -1330,7 +1321,7 @@ private void WalkItem<T>(string context, T state, Action<OpenApiWalker, T> walk)
13301321
/// <param name="walk">An action that walks objects within the context.</param>
13311322
private void WalkItem<T>(string context, T state, Action<OpenApiWalker, T, bool> walk, bool isComponent)
13321323
{
1333-
_visitor.Enter(ReplaceSlashes(context));
1324+
_visitor.Enter(context);
13341325
walk(this, state, isComponent);
13351326
_visitor.Exit();
13361327
}
@@ -1351,7 +1342,7 @@ private void WalkDictionary<T>(
13511342
{
13521343
if (state != null && state.Count > 0)
13531344
{
1354-
_visitor.Enter(ReplaceSlashes(context));
1345+
_visitor.Enter(context);
13551346

13561347
foreach (var item in state)
13571348
{

0 commit comments

Comments
 (0)