Eric-Shi / protobuf-java-format

Automatically exported from code.google.com/p/protobuf-java-format
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Should not use currentToken when xml tag is empty #21

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Try to convert a <object><string></string></object> into java instance,
will get a object.string equal to "</" instant of expected ""

Fix:
--- XmlFormat.java  2010-06-03 17:06:18.000000000 +0100
+++ XmlFormat.java  2010-10-14 17:52:51.500656265 +0100
@@ -392,6 +394,14 @@
             return currentToken.length() == 0;
         }

+        public String getCurrentToken() {
+            return currentToken;
+        }
+
+        public void setCurrentToken(String string) {
+            currentToken = string;
+        }
+
         /**
          * Advance to the next token.
          */
@@ -857,6 +867,10 @@

         tokenizer.consume(">");

+        if(tokenizer.getCurrentToken().equals("</")) {
+            tokenizer.setCurrentToken("");
+        }
+
         Object value = handleValue(tokenizer, extensionRegistry, builder, field, extension);

         if (field.isRepeated()) {

PS: Also should allow for short tags e.g. <data/> not only <data></data> which 
will be possible with this fix.

Original issue reported on code.google.com by mateus...@gmail.com on 14 Oct 2010 at 5:01

GoogleCodeExporter commented 8 years ago
Have you tested it with the latest protobuf-java-format version?

If yes, I'll update the code based on your submitted diff

Original comment by eliran.bivas on 1 Dec 2010 at 9:30

GoogleCodeExporter commented 8 years ago

Original comment by eliran.bivas on 3 May 2011 at 1:36

GoogleCodeExporter commented 8 years ago
This is still an issue as of version 1.2.

Original comment by dgk...@gmail.com on 1 Mar 2012 at 5:18

GoogleCodeExporter commented 8 years ago
Is this project dead?   This is a really handy project and I noticed it has not 
been updated in 3 years.  Google just release ProtoBuf 2.6.0 and I am not sure 
if it will impact this projects ability.

Plus there are defect reports piling up?

Original comment by mellowaredev on 4 Sep 2014 at 12:27