mx4j/src/core/mx4j/loading MLetParser.java,1.5,1.6

Jeremy Boynes <[email protected]> Wed, 09 Feb 2005 07:17:20 +0000
Newsgroups gmane.comp.java.mx4j.cvs
Message-ID <[email protected]>
Update of /cvsroot/mx4j/mx4j/src/core/mx4j/loading
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16521/src/core/mx4j/loading

Modified Files:
	MLetParser.java 
Log Message:
Fix for [ 1116557 ] Parsing problems with MLet files

Index: MLetParser.java
===================================================================
RCS file: /cvsroot/mx4j/mx4j/src/core/mx4j/loading/MLetParser.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** MLetParser.java	13 Nov 2004 16:38:32 -0000	1.5
--- MLetParser.java	9 Feb 2005 07:17:15 -0000	1.6
***************
*** 155,159 ****
        if (archive < 0) throw new MLetParseException("Missing ARCHIVE attribute");
  
!       code = attributes.indexOf(CODE_ATTR);
        object = attributes.indexOf(OBJECT_ATTR);
        if (code < 0 && object < 0) throw new MLetParseException("Missing CODE or OBJECT attribute");
--- 155,164 ----
        if (archive < 0) throw new MLetParseException("Missing ARCHIVE attribute");
  
!       int start = 0;
!       do
!       {
!          code = attributes.indexOf(CODE_ATTR, start);
!          start = code + 4;
!       } while (code != -1 && attributes.charAt(code + 4) == 'B');
        object = attributes.indexOf(OBJECT_ATTR);
        if (code < 0 && object < 0) throw new MLetParseException("Missing CODE or OBJECT attribute");
***************
*** 161,165 ****
  
        if (code >= 0)
!          tag.setCode(findAttributeValue(attributes, code, CODE_ATTR));
        else
           tag.setObject(findAttributeValue(attributes, object, OBJECT_ATTR));
--- 166,176 ----
  
        if (code >= 0)
!       {
!          String codeAttr = findAttributeValue(attributes, code, CODE_ATTR);
!          if (codeAttr.endsWith(".class")) {
!             codeAttr = codeAttr.substring(0, codeAttr.length()-6);
!          }
!          tag.setCode(codeAttr);
!       }
        else
           tag.setObject(findAttributeValue(attributes, object, OBJECT_ATTR));
***************
*** 198,210 ****
  
        int begin = content.indexOf('"', equal + 1);
!       if (begin < 0) throw new MLetParseException("Missing quotes for attribute value");
! 
!       // Ensure no garbage
!       if (content.substring(equal + 1, begin).trim().length() != 0) throw new MLetParseException("Invalid attribute value");
! 
!       int end = content.indexOf('"', begin + 1);
!       if (end < 0) throw new MLetParseException("Missing quote for attribute value");
  
!       return content.substring(begin + 1, end).trim();
     }
  
--- 209,234 ----
  
        int begin = content.indexOf('"', equal + 1);
!       String value;
!       if (begin == -1)
!       {
!          int end = equal;
!          while (++end < content.length())
!          {
!             char ch = content.charAt(end);
!             if (ch == '\r' || ch == '\n' || ch == '>') break;
!          }
!          if (end == content.length()) throw new MLetParseException("Missing end for value of attribute " + attribute);
!          value = content.substring(equal+1, end);
!       }
!       else
!       {
!          int end = content.indexOf('"', begin+1);
!          if (end == -1) throw new MLetParseException("Missing closing \" for value of attribute " + attribute);
!          value = content.substring(begin+1, end);
!       }
!       value = value.trim();
!       if (value.length() == 0) throw new MLetParseException("Invalid attribute value");
  
!       return value;
     }
  



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click