UweKeim / ZetaResourceEditor

Free multilingual, parallel .NET resource file editing

Home Page:https://www.zeta-resource-editor.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

.resx not being saved upon malformed xml/no exception thrown

robertgro opened this issue · comments

Anyone else encountering the issue that when the .resx file is being accidently or mistakenly malformed (e.g. have a ' character or duplicate tags in your document) then the app itself doesn't complain about the resource being malformed (not throwing any exception) but just proceeds to show that the changes have been saved without letting the user know that the change weren't applied properly to the resource by the app? Even if you start the editor as Administrator the app doesn't obviously verify the validity of the XML. It shouldn't load the file and it should throw an exception in case of any failure.

Steps to reproduce:

  1. Have a malformed .resx
  2. Open the resource file directly (not in a project file) in Zeta Editor, make changes to the file/tags, click on save/save all files
  3. No change applied to the malformed .resx and also no error message shown that something went wrong

What do you consider as a "malformed .resx"?

For me, a malformed .resx contains duplicate element entries or special characters like ' (Apostrophe) in element attributes value. A recent test with two not well formed .resx files has shown the following:

Example_01 has a duplicate entry in it (lended by https://gist.github.com/bosskovic/5344285)

<root>
	<data name="Common_AuthenicationFailed" xml:space="preserve">
    <value>Authentifikation fehlgeschlagen</value>
  </data>
	<!-- single line comment -->
	<data name="Common_Billable" xml:space="preserve">
    <value>Verrechenbar</value>
  </data>
	<!-- multi
  line
  comment -->
	<data name="Common_BreakTime" xml:space="preserve">
    <value>Pausen1</value>
  </data>
	<data name="Common_BreakTime" xml:space="preserve">
    <value>Pausen</value>
  </data>
</root>

Example_02 contains an special character in an elements attribute value

<root>
	<data name="Common_AuthenicationFailed" xml:space="preserve">
    <value>Authentifikation fehlgeschlagen</value>
  </data>
	<!-- single line comment -->
	<data name="Common_Billable" xml:space="preserve">
    <value>Verrechenbar'</value>
  </data>
	<!-- multi
  line
  comment -->
	<data name="Common_BreakTime'" xml:space="preserve">
    <value>Pausen'_</value>
  </data>
	<data name="Common_BreakTime" xml:space="preserve">
		<value>Pausen1</value>
	</data>
</root>

If you open the files one by one, then you are able to save them properly without any complains (couldn't reproduce the behaviour in this scenario as of now). As soon as you open them both concurrently, changes are not applied as they should, leading to even more duplicates.

Thank you, @robertgro.

I can think of one way to deal with is to develop a validation logic and apply it to every RESX file that is about to open and then reject (i.e. throw an exception) the opening of the document.

Currently, primarily due to time and ideas, this is out of scope for me.

I would be more than happy if you submit a pull request for such a validation 🙂

You are welcome. We encountered the issue ourself in our development environment. The logic itself shouldn't be that hard to implement, that's correct. If my capacities allow me to spend some time on this I'll surely submit a pull request, because we keep working with your app. 👍