Revision: 2148
          http://vexi.svn.sourceforge.net/vexi/?rev=2148&view=rev
Author:   mkpg2
Date:     2007-09-08 17:56:24 -0700 (Sat, 08 Sep 2007)

Log Message:
-----------
Fix. Entites in xml attributes now interpreted.

Modified Paths:
--------------
    trunk/core/org.ibex.util/src/org/ibex/util/XML.java

Modified: trunk/core/org.ibex.util/src/org/ibex/util/XML.java
===================================================================
--- trunk/core/org.ibex.util/src/org/ibex/util/XML.java 2007-09-09 00:15:06 UTC 
(rev 2147)
+++ trunk/core/org.ibex.util/src/org/ibex/util/XML.java 2007-09-09 00:56:24 UTC 
(rev 2148)
@@ -499,6 +499,7 @@
         }
         col++; off++; len--;
 
+        StringBuffer sb = new StringBuffer();
         // find the attribute value
         attval: for (ref = 0; ; ref++) {
             if (!buffer(ref+1)) throw new EOFException("Unexpected EOF in 
attribute value");
@@ -507,10 +508,17 @@
                 break attval;
             } else if (buf[off+ref] == '<') {
                 throw new Exn("attribute value for '"+n+"' must not contain 
'<'", Exn.WFC, getLine(), getCol());
-            } 
+            }
+            switch(buf[off+ref]){
+            case '&':  // entity
+               off += ref; len -= ref; ref = -1;
+               sb.append(readEntity()[0]);break;
+            default:
+               sb.append(buf[off+ref]);
+            }
         }
 
-        v = new String(buf, off, ref);
+        v = sb.toString();
         col += ref; off += ref; len -= ref;
 
         // remove end wrapper character
@@ -540,11 +548,10 @@
     }
 
     /** reads an entity and processes out its value. expects buf[off] == 
'&amp;' */
-    private final void readEntity() throws IOException, Exn {
+    private final char[] readEntity() throws IOException, Exn {
         off++; len--;
         if (!buffer(2)) throw new EOFException("Unexpected EOF reading 
entity");
 
-        boolean unknown = false;
         switch (buf[off]) {
             case '#':
                 off++; len--;
@@ -569,52 +576,41 @@
                 }
 
                 singlechar[0] = (char) c;
-                characters(singlechar, 0, 1);
-                break;
-
+                return singlechar;
             case 'a':
                 if (buffer(4) && buf[off+1] == 'm' && buf[off+2] == 'p' && 
buf[off+3] == ';') {
-                    characters(single_amp, 0, 1); // &amp;
                     off += 4; len -= 4; col++;
+                    return single_amp;
                 } else if (buffer(5) && buf[off+1] == 'p' && buf[off+2] == 'o' 
&& buf[off+3] == 's' && buf[off+4] == ';') {
-                    characters(single_apos, 0, 1); // &apos;
                     off += 5; len -= 5; col++;
-                } else {
-                    unknown = true;
-                }
+                    return single_apos;
+                } 
                 break;
 
             case 'g':
                 if (buffer(3) && buf[off+1] == 't' && buf[off+2] == ';') {
-                    characters(single_gt, 0, 1); // &gt;
                     off += 3; len -= 3; col++;
-                } else {
-                    unknown = true;
-                }
+                    return single_gt; // &gt;
+                } 
                 break;
 
             case 'l':
                 if (buffer(3) && buf[off+1] == 't' && buf[off+2] == ';') {
-                    characters(single_lt, 0, 1); // &lt;
-                    off += 3; len -= 3; col++;
-                } else {
-                    unknown = true;
+                       off += 3; len -= 3; col++;
+                       return single_lt; // &lt;
                 }
                 break;
 
             case 'q':
                 if (buffer(5) && buf[off+1] == 'u' && buf[off+2] == 'o' && 
buf[off+3] == 't' && buf[off+4] == ';') {
-                    characters(single_quot, 0, 1); // &quot;
                     off += 5; len -= 5; col++;
-                } else {
-                    unknown = true;
+                    return single_quot; // &quot;
                 }
                 break;
 
             // TODO: check a parser-level Hash of defined entities
         }
-
-        if (unknown) throw new Exn("unknown entity (<!ENTITY> not supported)", 
Exn.WFC, getLine(), getCol());
+        throw new Exn("unknown entity (<!ENTITY> not supported)", Exn.WFC, 
getLine(), getCol());
     }
 
     /** reads until the passed string is encountered. */
@@ -654,7 +650,7 @@
                             if (p) {
                                 if (ref > 0) characters(buf, off, ref);
                                 off += ref; len -= ref; ref = -1;
-                                readEntity();
+                                characters(readEntity(),0,1);
                             }
                             break;
                         }
@@ -733,7 +729,7 @@
                         if (p) {
                             if (ref > 0) characters(buf, off, ref);
                             off += ref; len -= ref; ref = -1;
-                            readEntity();
+                            characters(readEntity(),0,1);
                         }
                     default:
                         lastWhite = false;


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Vexi-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/vexi-svn

Reply via email to