File tree Expand file tree Collapse file tree
LocalizationManager.Core/Backends/iOS Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22// Licensed under the MIT License
33
44using System . Text ;
5+ using System . Xml ;
56using System . Xml . Linq ;
67
78namespace LocalizationManager . Core . Backends . iOS ;
@@ -34,7 +35,21 @@ public List<StringsdictEntry> Parse(string content)
3435
3536 try
3637 {
37- var doc = XDocument . Parse ( content ) ;
38+ // Use secure XML settings to prevent XXE attacks
39+ // Note: Use Ignore instead of Prohibit to handle Apple's DOCTYPE declarations
40+ // Ignore still prevents external entity resolution via XmlResolver = null
41+ var settings = new XmlReaderSettings
42+ {
43+ DtdProcessing = DtdProcessing . Ignore ,
44+ XmlResolver = null
45+ } ;
46+
47+ XDocument doc ;
48+ using ( var reader = XmlReader . Create ( new StringReader ( content ) , settings ) )
49+ {
50+ doc = XDocument . Load ( reader ) ;
51+ }
52+
3853 var plist = doc . Element ( "plist" ) ;
3954 var rootDict = plist ? . Element ( "dict" ) ;
4055
@@ -88,15 +103,7 @@ public List<StringsdictEntry> Parse(string content)
88103 case "NSStringLocalizedFormatKey" :
89104 formatKey = propValue . Value ;
90105 // Extract variable name from format like "%#@count@"
91- if ( formatKey . Contains ( "@" ) )
92- {
93- var start = formatKey . IndexOf ( '@' ) + 1 ;
94- var end = formatKey . LastIndexOf ( '@' ) ;
95- if ( end > start )
96- {
97- variableName = formatKey . Substring ( start , end - start ) ;
98- }
99- }
106+ variableName = ExtractVariableName ( formatKey ) ;
100107 break ;
101108
102109 default :
You can’t perform that action at this time.
0 commit comments