-
Notifications
You must be signed in to change notification settings - Fork 92
Change default encoding in XML.save to UTF-8 #122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Is it worthwhile to add a |
@ashawley In that case we will need to create another method ( |
Oh, right. I didn't mean deprecate. Sorry about that. Is there a way to emit a warning that the behavior of the method has changed? |
@ashawley - never saw anything like that. And since scala does not have any method for silencing warnings, I doubt there is one (else everybody would be stuck looking at that warning message on each compilation). |
Ok, good points. Maybe add a note in the method's documentation about the change then? We'll have to notify the town crier as well. |
Done. Who's the town crier? |
we can town-cry about it in the release notes for whatever Scala 2.12.x version bumps the scala-xml module version to include this |
src/main/scala/scala/xml/XML.scala
Outdated
@@ -74,6 +74,10 @@ object XML extends XMLLoader[Elem] { | |||
* Saves a node to a file with given filename using given encoding | |||
* optionally with xmldecl and doctype declaration. | |||
* | |||
* Note: default encoding was ISO-8859-1 (latin1) in pre-1.0.7 scala-xml versions. | |||
* If your code depends on charaters in non-ASCII latin1 range, specify |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/charaters/characters/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shame on me :(
Try to closely mimic bug in XML.save and XML.loadFile, but write tests that don't use the file system. Will fail in 1.0.6 and earlier: expected:<...klmnopqrstuvwxyz{|}~[ ¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ]</x>> but was:<...klmnopqrstuvwxyz{|}~[????????????????????????????????????????????????????????????????????????????????????????????????]</x>> Will be fixed in scala#122.
Unit test in another PR that will fail, but will be fixed by this PR. |
@ashawley Should I include that test in this PR? |
Sure. Feel free to cherry-pick or rebase in here. |
Try to closely mimic bug in XML.save and XML.loadFile, but write tests that don't use the file system. Will fail in 1.0.6 and earlier: expected:<...klmnopqrstuvwxyz{|}~[ ¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ]</x>> but was:<...klmnopqrstuvwxyz{|}~[????????????????????????????????????????????????????????????????????????????????????????????????]</x>> Will be fixed in scala#122.
Is there something else I need to do to get this PR accepted? |
needs rebase now. LGTM otherwise and I would suggest we merge in a few days, after the rebase, if there are no actual objections |
Try to closely mimic bug in XML.save and XML.loadFile, but write tests that don't use the file system. Will fail in 1.0.6 and earlier: expected:<...klmnopqrstuvwxyz{|}~[ ¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ]</x>> but was:<...klmnopqrstuvwxyz{|}~[????????????????????????????????????????????????????????????????????????????????????????????????]</x>> Will be fixed in scala#122.
Done. Seems rebase loses commit times, sadly (I'm more used to merge workflow). |
are you sure? I don't think so (regardless, thanks for taking care of it) |
I see it now - my log viewer was set up to display commiter ( |
Still LGTM! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
If you could do one more rebase and push, I'll merge this, tomorrow. |
Was ISO-8859-1, which resulted in encoding errors at runtime if document contained non-latin1 characters. Also XML spec states that documents without xml declaration are expected to contain UTF-8 or UTF-16 - so writing in ISO-8859-1 without xml declaration (which was the default) can easily break compliant parsers.
Try to closely mimic bug in XML.save and XML.loadFile, but write tests that don't use the file system. Will fail in 1.0.6 and earlier: expected:<...klmnopqrstuvwxyz{|}~[ ¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ]</x>> but was:<...klmnopqrstuvwxyz{|}~[????????????????????????????????????????????????????????????????????????????????????????????????]</x>> Will be fixed in scala#122.
@ashawley - Done. As a side note, I have huge troubles with rebase workflow - in this case, for example, I had to rebase the changes, thus rewriting history, and then had to do |
Thanks for responding so quickly. And apologies, for troubling you by repeatedly asking you to rebase. Especially, if you aren't used to our git workflow. Yes, rebase does rewrite git history on your branch. It looks like your branch name for this PR is called
Hope that helps! |
Thanks for the explanation! No, master branch does not give much trouble (though it will be a little bit more convenient if I did name the PR branch differently). But the thought of routinely doing |
Yeah, push force is weird. In addition to |
Was ISO-8859-1, which resulted in encoding errors at runtime if document
contained non-latin1 characters. Also XML spec states that
documents without xml declaration are expected to contain UTF-8 or UTF-16,
so writing in ISO-8859-1 without xml declaration (which was the default)
can easily break compliant parsers.