yck1509 / ConfuserEx

An open-source, free protector for .NET applications
http://yck1509.github.io/ConfuserEx/
Other
3.57k stars 1.64k forks source link

xaml [] parse #554

Open m506 opened 8 years ago

m506 commented 8 years ago

I have a xaml file with the following line:

<s:String x:Key="TT3846">Specific filename date/time identifiers within brackets []. Example: Export1_[yyyyMMdd_hhmmss].txt</s:String>

This is crashing the app with the error below, which I think is because the code is not considering the string [] properly when parsing text.

Exception: System.IndexOutOfRangeException: Index was outside the bounds of the array. at System.String.get_Chars(Int32 index) at Confuser.Renamer.BAML.PropertyPath.ReadIndexer(String path, Int32& index, Nullable1 isHiera) in d:\Downloads\ConfuserEx-8d5fa66f1066e82f25465cd77fe56bc66bea2c47\ConfuserEx-8d5fa66f1066e82f25465cd77fe56bc66bea2c47\Confuser.Renamer\BAML\PropertyPath.cs:line 82 at Confuser.Renamer.BAML.PropertyPath.Parse(String path) in d:\Downloads\ConfuserEx-8d5fa66f1066e82f25465cd77fe56bc66bea2c47\ConfuserEx-8d5fa66f1066e82f25465cd77fe56bc66bea2c47\Confuser.Renamer\BAML\PropertyPath.cs:line 214 at Confuser.Renamer.BAML.PropertyPath..ctor(String path) in d:\Downloads\ConfuserEx-8d5fa66f1066e82f25465cd77fe56bc66bea2c47\ConfuserEx-8d5fa66f1066e82f25465cd77fe56bc66bea2c47\Confuser.Renamer\BAML\PropertyPath.cs:line 59 at Confuser.Renamer.BAML.BAMLAnalyzer.AnalyzePropertyPath(String path) in d:\Downloads\ConfuserEx-8d5fa66f1066e82f25465cd77fe56bc66bea2c47\ConfuserEx-8d5fa66f1066e82f25465cd77fe56bc66bea2c47\Confuser.Renamer\BAML\BAMLAnalyzer.cs:line 560 at Confuser.Renamer.BAML.BAMLAnalyzer.ProcessElementBody(BamlElement root, BamlElement elem) in d:\Downloads\ConfuserEx-8d5fa66f1066e82f25465cd77fe56bc66bea2c47\ConfuserEx-8d5fa66f1066e82f25465cd77fe56bc66bea2c47\Confuser.Renamer\BAML\BAMLAnalyzer.cs:line 422 at Confuser.Renamer.BAML.BAMLAnalyzer.ProcessBAMLElement(BamlElement root, BamlElement elem) in d:\Downloads\ConfuserEx-8d5fa66f1066e82f25465cd77fe56bc66bea2c47\ConfuserEx-8d5fa66f1066e82f25465cd77fe56bc66bea2c47\Confuser.Renamer\BAML\BAMLAnalyzer.cs:line 263 at Confuser.Renamer.BAML.BAMLAnalyzer.Analyze(ModuleDefMD module, String bamlName, Byte[] data) in d:\Downloads\ConfuserEx-8d5fa66f1066e82f25465cd77fe56bc66bea2c47\ConfuserEx-8d5fa66f1066e82f25465cd77fe56bc66bea2c47\Confuser.Renamer\BAML\BAMLAnalyzer.cs:line 123 at Confuser.Renamer.Analyzers.WPFAnalyzer.AnalyzeResources(ConfuserContext context, INameService service, ModuleDefMD module) in d:\Downloads\ConfuserEx-8d5fa66f1066e82f25465cd77fe56bc66bea2c47\ConfuserEx-8d5fa66f1066e82f25465cd77fe56bc66bea2c47\Confuser.Renamer\Analyzers\WPFAnalyzer.cs:line 329 at Confuser.Renamer.Analyzers.WPFAnalyzer.Analyze(ConfuserContext context, INameService service, ProtectionParameters parameters, IDnlibDef def) in d:\Downloads\ConfuserEx-8d5fa66f1066e82f25465cd77fe56bc66bea2c47\ConfuserEx-8d5fa66f1066e82f25465cd77fe56bc66bea2c47\Confuser.Renamer\Analyzers\WPFAnalyzer.cs:line 36 at Confuser.Renamer.AnalyzePhase.Analyze(NameService service, ConfuserContext context, ProtectionParameters parameters, IDnlibDef def, Boolean runAnalyzer) in d:\Downloads\ConfuserEx-8d5fa66f1066e82f25465cd77fe56bc66bea2c47\ConfuserEx-8d5fa66f1066e82f25465cd77fe56bc66bea2c47\Confuser.Renamer\AnalyzePhase.cs:line 134 at Confuser.Renamer.AnalyzePhase.Execute(ConfuserContext context, ProtectionParameters parameters) in d:\Downloads\ConfuserEx-8d5fa66f1066e82f25465cd77fe56bc66bea2c47\ConfuserEx-8d5fa66f1066e82f25465cd77fe56bc66bea2c47\Confuser.Renamer\AnalyzePhase.cs:line 55 at Confuser.Core.ProtectionPipeline.ExecuteStage(PipelineStage stage, Action1 func, Func`1 targets, ConfuserContext context) in d:\Downloads\ConfuserEx-8d5fa66f1066e82f25465cd77fe56bc66bea2c47\ConfuserEx-8d5fa66f1066e82f25465cd77fe56bc66bea2c47\Confuser.Core\ProtectionPipeline.cs:line 138 at Confuser.Core.ConfuserEngine.RunPipeline(ProtectionPipeline pipeline, ConfuserContext context) in d:\Downloads\ConfuserEx-8d5fa66f1066e82f25465cd77fe56bc66bea2c47\ConfuserEx-8d5fa66f1066e82f25465cd77fe56bc66bea2c47\Confuser.Core\ConfuserEngine.cs:line 219 at Confuser.Core.ConfuserEngine.RunInternal(ConfuserParameters parameters, CancellationToken token) in d:\Downloads\ConfuserEx-8d5fa66f1066e82f25465cd77fe56bc66bea2c47\ConfuserEx-8d5fa66f1066e82f25465cd77fe56bc66bea2c47\Confuser.Core\ConfuserEngine.cs:line 173

Shujee commented 7 years ago

I can reproduce this issue and can confirm that this is happening because a particular XAML file contains a TextBlock with square brackets ("[" and "]") in its Text property. The property value has been assigned directly as literal string child of the TextBlock element. For example:

<TextBlock>
  Confuser will be [confused] by this string.
</TextBlock>

@m506 👍 Your post helped me a lot.