Skip to content

Commit

Permalink
Merge branch 'hotfix-log4j'
Browse files Browse the repository at this point in the history
  • Loading branch information
AlphaBs committed Dec 20, 2021
2 parents 1cf3d0f + 0f55035 commit 09a6796
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 14 deletions.
2 changes: 1 addition & 1 deletion CmlLib/CmlLib.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFrameworks>net462;netstandard2.0</TargetFrameworks>
<LangVersion>8.0</LangVersion>
<Nullable>enable</Nullable>
<Version>3.3.4</Version>
<Version>3.3.5</Version>
<Description>Minecraft Launcher Library for .NET
Support all version, forge, optifine
</Description>
Expand Down
4 changes: 2 additions & 2 deletions CmlLib/Core/Installer/MForge.cs
Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,8 @@ private bool checkProcessorOutputs(JObject outputs, Dictionary<string, string> m
{
foreach (var outitem in outputs)
{
var key = Mapper.Interpolation(outitem.Key, mapData);
var value = Mapper.Interpolation(outitem.Value.ToString(), mapData);
var key = Mapper.Interpolation(outitem.Key, mapData, true);
var value = Mapper.Interpolation(outitem.Value.ToString(), mapData, true);

if (!File.Exists(key) || !IOUtil.CheckSHA1(key, value))
return false;
Expand Down
2 changes: 1 addition & 1 deletion CmlLib/Core/Launcher/MLaunch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public string[] CreateArg()
args.Add(Mapper.Interpolation(version.LoggingClient?.Argument, new Dictionary<string, string?>()
{
{ "path", minecraftPath.GetLogConfigFilePath(version.LoggingClient?.Id ?? version.Id) }
}));
}, true));

// main class
if (!string.IsNullOrEmpty(version.MainClass))
Expand Down
23 changes: 13 additions & 10 deletions CmlLib/Core/Mapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ public static string[] Map(string[] arg, Dictionary<string, string?> dicts, stri
var args = new List<string>(arg.Length);
foreach (string item in arg)
{
var a = Interpolation(item, dicts);
var a = Interpolation(item, dicts, false);
if (checkPath)
a = ToFullPath(a, prepath);
args.Add(handleEArg(a));
args.Add(HandleEmptyArg(a));
}

return args.ToArray();
Expand All @@ -30,8 +30,8 @@ public static string[] MapInterpolation(string[] arg, Dictionary<string, string?
var args = new List<string>(arg.Length);
foreach (string item in arg)
{
var a = Interpolation(item, dicts);
args.Add(handleEArg(a));
var a = Interpolation(item, dicts, true);
args.Add(a);
}

return args.ToArray();
Expand All @@ -43,15 +43,15 @@ public static string[] MapPathString(string[] arg, string prepath)
foreach (string item in arg)
{
var a = ToFullPath(item, prepath);
args.Add(handleEArg(a));
args.Add(HandleEmptyArg(a));
}

return args.ToArray();
}

public static string Interpolation(string str, Dictionary<string, string?> dicts)
public static string Interpolation(string str, Dictionary<string, string?> dicts, bool handleEmpty)
{
str = argBracket.Replace(str, new MatchEvaluator((match =>
str = argBracket.Replace(str, (match =>
{
if (match.Groups.Count < 2)
return match.Value;
Expand All @@ -66,9 +66,12 @@ public static string Interpolation(string str, Dictionary<string, string?> dicts
}

return match.Value;
})));
}));

return str;
if (handleEmpty)
return HandleEmptyArg(str);
else
return str;
}

public static string ToFullPath(string str, string prepath)
Expand Down Expand Up @@ -114,7 +117,7 @@ static string replaceByPos(StringBuilder sb, string replace, int startIndex, int
// key="va l" => key="va l"
// va lue => "va lue"
// "va lue" => "va lue"
static string handleEArg(string input)
public static string HandleEmptyArg(string input)
{
if (input.Contains("="))
{
Expand Down

0 comments on commit 09a6796

Please sign in to comment.