anydoby / 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

Cannot merge value string with non alphanumeric characters such as '.' #19

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.create a simple protobuf message, message CharTest{required string a=1}
2.create a protobuf instance, with a=
3. CharTest m CharTest.newBuilder().setA("my.test").build();
   String xmlText =  XmlFormat.printToString(m);
   UserAuthReq.Builder builder2 = UserAuthReq.newBuilder();   
   XmlFormat.merge(xmlText, builder2);

What is the expected output? What do you see instead?
It should run without exception. 
Actual output:
com.google.protobuf.XmlFormat$ParseException: 1:33: Expected ">".
        at com.google.protobuf.XmlFormat$Tokenizer.parseException(XmlFormat.java:662)
        at com.google.protobuf.XmlFormat$Tokenizer.consume(XmlFormat.java:461)
        at com.google.protobuf.XmlFormat.consumeClosingElement(XmlFormat.java:785)
        at com.google.protobuf.XmlFormat.mergeField(XmlFormat.java:869)
        at com.google.protobuf.XmlFormat.merge(XmlFormat.java:768)
        at com.google.protobuf.XmlFormat.merge(XmlFormat.java:734)
        at com.google.protobuf.XmlFormat.merge(XmlFormat.java:709)

What version of the product are you using? On what operating system?
protobuf-java-format 1.1, protobuf-2.3, Linux

This seems to be the way how to handle the nextToken. it doens't match the 
Token pattern.

Original issue reported on code.google.com by sean...@gmail.com on 6 Aug 2010 at 3:29

GoogleCodeExporter commented 9 years ago
I'm also having this issue, specifically when spaces are used.

Original comment by basta...@gmail.com on 13 Sep 2010 at 10:20

GoogleCodeExporter commented 9 years ago
the current TOKEN format doesn't support valid text content -- not sure if 
removing the quotes is enough / will break other bits, eg attributes. Probably 
need a separate regexp i think.

Original comment by ken.h...@gmail.com on 8 Dec 2010 at 2:05

GoogleCodeExporter commented 9 years ago
Hello,

I still seem to be having this problem. I am using the most recent code, but 
without any luck. I saw that this issue has been closed a long time ago. I 
downloaded the most recent source code and tried again, but the problem 
persists. If anyone has any idea about this, please let me know.

Thanks,
Meghana.

Original comment by meghana....@gmail.com on 4 Jan 2011 at 4:47

GoogleCodeExporter commented 9 years ago
OK I had exactly the same issue and for My personal project I create this class
Based on the XmlFormat Class (merging part)

this class DOES NOT HANDLE well extension (if you wants to manage just edit 
that class look at TODO thing I copy the old function but I don't manage well 
extraction of extension name)

this class use same mechanism as XmlFormat but use DomParser to parse XML 
instead of the Tokenizer
I suppose that using dom parser instead of Tokenizer use more CPU/Time but 
-as I encounter a lot of issue with tokenizer and special character or 
whitespace a 
-and as I use that for loading data (not real time process) it is best for me

feel free to use / copy /reorganize/ any part of that

Original comment by Guillaum...@gmail.com on 3 Feb 2011 at 4:20

Attachments:

GoogleCodeExporter commented 9 years ago
Still the same issues in 1.1.1.
Any chance that this gets fixed soon?

Original comment by stephan....@gmail.com on 2 Apr 2011 at 8:36

GoogleCodeExporter commented 9 years ago
This is basically the same problem as documented in issue 10. For a workaround 
see: http://code.google.com/p/protobuf-java-format/issues/detail?id=10#c16 for 

Original comment by stephan....@gmail.com on 4 Apr 2011 at 2:35

GoogleCodeExporter commented 9 years ago

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

GoogleCodeExporter commented 9 years ago
maybe someone might find this comment helpful, too: 
http://code.google.com/p/protobuf-java-format/issues/detail?id=10#c25

stephan

Original comment by stephan....@gmail.com on 5 May 2011 at 5:04