Skip to content

Commit 906de44

Browse files
committed
validate search and replace XML with one xmlns
1 parent bdb7750 commit 906de44

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

OneMore/Commands/Search/SearchAndReplaceDialog.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,20 @@ private void CheckXmlFormat(object sender, EventArgs e)
182182
{
183183
if (rawBox.Checked)
184184
{
185+
// rawBox lets users replace content with XML snippets;
186+
// it does not replace XML with xML!
187+
185188
var xml = withBox.Text.Trim();
186189
try
187190
{
191+
// if XML then ensure the 'one' prefix is defined as an xmlns...
192+
193+
var match = Regex.Match(xml, @"^<(?:(?<prefix>\w+):)?\w+(?<space>\s*)>");
194+
if (match.Success && match.Groups["prefix"].Length > 0)
195+
{
196+
xml = xml.Insert(6, $" xmlns:{match.Groups["prefix"].Value}='anything'");
197+
}
198+
188199
RawXml = XElement.Parse(xml);
189200
}
190201
catch

0 commit comments

Comments
 (0)