qiuwei / jing-trang

Automatically exported from code.google.com/p/jing-trang
Other
1 stars 1 forks source link

I think there is a bug in trunk/mod/util/src/main/com/thaiopensource/xml/util/Naming.java #68

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I think there is a bug in that method :

 public static boolean isQname(String s) {
    int len = s.length();
    if (len == 0)
      return false;
    if (!isNameStartCharNs(s.charAt(0)))
      return false;
    for (int i = 1; i < len; i++) {
      char c = s.charAt(i);
      if (!isNameChar(c)) {
        if (c == ':' && ++i < len && isNameStartCharNs(s.charAt(i))) {
          for (++i; i < len; i++)
            if (!isNameCharNs(s.charAt(i)))
              return false;
          return true;
        }
        return false;
      }
    }
    return true;
  }

The test if (!isNameChar(c)) {
will return false if c is ':' so it will not come to the next line.
I think that line should be replaced by 

if (!isNameCharNs(c)) {

See Junit attached

Original issue reported on code.google.com by ndebeiss@gmail.com on 26 Jan 2009 at 3:11

Attachments:

GoogleCodeExporter commented 8 years ago
Thanks!
Fixed in r2318.

Original comment by georgebina76 on 26 Jan 2009 at 4:52

GoogleCodeExporter commented 8 years ago
Add some test cases in r2322.

Original comment by jjc.jclark.com on 5 Feb 2009 at 4:19