Menu

#389 Any characters with code greater than 7f are written to XML attribute value as entity

v2.5.*
closed-fixed
None
2.5.3
5
2016-06-20
2016-06-05
Anton
No

All characters with code greater than 7f are written to XML attribute value as character literal.
This is because XmlWriter has wrong checking condition:

                    if ((currentChar > 0x7f) || !isValidXmlChar(currentChar))
                    {
                        entity = "&#" + String.valueOf((int) currentChar) + ";";
                    }

should be

                    if ((currentChar > 0x7f) && !isValidXmlChar(currentChar))
                    {
                        entity = "&#" + String.valueOf((int) currentChar) + ";";
                    }

Another problem is that isValidXmlChar() parameter is 'char' so third condition in this method is always false. Parameter shoud be changed to int. This is not complete solution for the problem buf fixes isValidXmlChar() method.

Related

Bugs: #389
dbunit: 61aa94d1

Discussion

  • Jeff Jensen

    Jeff Jensen - 2016-06-05
    • status: open --> pending
     
  • Jeff Jensen

    Jeff Jensen - 2016-06-05

    Thanks for reporting.
    I extracted the switch to a method to help with testing this and pushed it.

    Since you have the context and situation that causes the problem(s), would you mind taking this issue further and writing tests to prove the issues along with the fixes and then providing them as a patch or merge request please?

     
  • Anton

    Anton - 2016-06-06

    I've created test, fix and already placed merge request.

     
  • Jeff Jensen

    Jeff Jensen - 2016-06-06

    Please rebase from master so the merge is clean.

     
  • Jeff Jensen

    Jeff Jensen - 2016-06-11

    Do you need more time to resolve further or did you give up on this one?

     
  • Anton

    Anton - 2016-06-12

    I've rebased from master and provided new pull request. Did you see it?

     
  • Jeff Jensen

    Jeff Jensen - 2016-06-12

    Perhaps you didn't see my comment on it:

    Thanks. I encounter this problem with this commit merged:
    Failed tests:
    XmlWriterTest.testEncodedXmlChar:166 expected:<<COLUMN1 ATTR="&lt;span&gt;&lt;span&gt;[klzzwxh:0000text1klzzwxh:0001text2klzzwxh:0002text3klzzwxh:0003" klzzwxh:0000klzzwxh:0004text1klzzwxh:0001#xklzzwxh:0007A;text2klzzwxh:0005text3klzzwxh:0006]<="" span=""><="" span=""></COLUMN1>
    but was:<<COLUMN1 ATTR="&lt;span&gt;&lt;span&gt;[«text1klzzwxh:0012text2klzzwxh:0013text3«" klzzwxh:0003«text1klzzwxh:0014text2klzzwxh:0015text3«]<="" span=""><="" span=""></COLUMN1>

    Does it pass for you?

     
    • Anton

      Anton - 2016-06-13

      Sorry. I've missed it.
      Expected value in this test was wrong because it contained a valid XML char
      (174=0xAE) in encoded form.
      I've fixed it too.

      Another point is that method convertCharacterToEntity() encodes '\r', '\n'
      and '\t'. Is it expected behavior?

      On Mon, Jun 13, 2016 at 12:10 AM, Jeff Jensen jeffjensen@users.sf.net
      wrote:

      Perhaps you didn't see my comment on it:

      Thanks. I encounter this problem with this commit merged:
      Failed tests:
      XmlWriterTest.testEncodedXmlChar:166 expected:<<COLUMN1
      ATTR="<span><span>[klzzwxh:0000text1klzzwxh:0001text2klzzwxh:0002text3klzzwxh:0003"
      klzzwxh:0000 klzzwxh:0004text1 klzzwxh:0001

      xklzzwxh:0007A;text2klzzwxh:0005text3klzzwxh:0006]<="" span=""><=""

      span=""></COLUMN1>
      but was:<<COLUMN1 ATTR="&lt;span&gt;&lt;span&gt;&lt;span&gt;[«text1klzzwxh:0012text2klzzwxh:0013text3«" klzzwxh:0017klzzwxh:0003="" «text1klzzwxh:0014text2klzzwxh:0015text3«]<="" span=""><="" span=""><=""
      span=""></COLUMN1>

      Does it pass for you?

      Status: pending
      Fixed Release: (not fixed)
      Found Release: v2.5.
      Created: Sun Jun 05, 2016 04:17 PM UTC by Anton
      Last Updated: Sun Jun 12, 2016 06:18 PM UTC
      Owner:* Jeff Jensen

      All characters with code greater than 7f are written to XML attribute
      value as character literal.
      This is because XmlWriter has wrong checking condition:

                      if ((currentChar > 0x7f) || !isValidXmlChar(currentChar))
                      {
                          entity = "&#" + String.valueOf((int) currentChar) + ";";
                      }
      

      should be

                      if ((currentChar > 0x7f) && !isValidXmlChar(currentChar))
                      {
                          entity = "&#" + String.valueOf((int) currentChar) + ";";
                      }
      

      Another problem is that isValidXmlChar() parameter is 'char' so third
      condition in this method is always false. Parameter shoud be changed to
      int. This is not complete solution for the problem buf fixes
      isValidXmlChar() method.


      Sent from sourceforge.net because you indicated interest in
      https://sourceforge.net/p/dbunit/bugs/389/

      To unsubscribe from further messages, please visit
      https://sourceforge.net/auth/subscriptions/

       

      Related

      Bugs: #389

  • Anton

    Anton - 2016-06-13

    An expected value in mentioned test was wrong because it expects a valid XML char (174=0xAE) in encoded form.
    I've fixed it too in 'xmlwriter' branch .

    Another point is that method convertCharacterToEntity() encodes '\r', '\n' and '\t'. Is it expected behavior?

     
  • Jeff Jensen

    Jeff Jensen - 2016-06-13

    Thanks for reviewing and fixing. Please publish a new merge request.

     
  • Jeff Jensen

    Jeff Jensen - 2016-06-20

    Thanks, merged.

    Another point is that method convertCharacterToEntity() encodes '\r', '\n' and '\t'. Is it expected behavior?

    I'm not familiar with that code and I rarely have used this feature area. Does it work well this way and as you would expect using it or not?

     

    Last edit: Jeff Jensen 2016-06-20
  • Jeff Jensen

    Jeff Jensen - 2016-06-20
    • status: pending --> closed-fixed
    • Fixed Release: (not fixed) --> 2.5.3
     

Log in to post a comment.