wwtaourl / openid4java

Automatically exported from code.google.com/p/openid4java
0 stars 0 forks source link

Parsing KeyValue message with trailing newline fails #88

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Parse KeyValue message with extra newline at the end
2. org.openid4java.message.MessageException: 0x100: Invalid Key-Value form,
colon missing: 

What version of the product are you using? On what operating system?
Latest rev.

Please provide any additional information below.

diff --git a/src/org/openid4java/message/ParameterList.java
b/src/org/openid4java/message/ParameterList.java
index 155b723..4b004bf 100644
--- a/src/org/openid4java/message/ParameterList.java
+++ b/src/org/openid4java/message/ParameterList.java
@@ -189,7 +189,7 @@ public class ParameterList implements Serializable

         ParameterList parameterList = new ParameterList();

-        StringTokenizer tokenizer = new StringTokenizer(keyValueForm, "\n");
+        StringTokenizer tokenizer = new
StringTokenizer(keyValueForm.trim(), "\n");
         while (tokenizer.hasMoreTokens())
         {
             String keyValue = tokenizer.nextToken();

Original issue reported on code.google.com by andrefcruz on 23 Feb 2009 at 2:06

GoogleCodeExporter commented 8 years ago
Can confirm this, although I thought it was a server implementation error. If 
the
server responds to a POST request with println instead of print. Maybe ignoring 
empty
tokens would increase compatibility towards providers.

Original comment by guj...@gmail.com on 24 Feb 2009 at 12:37

GoogleCodeExporter commented 8 years ago
Actually, this issue is the same as the issue 15 which was invalid ;)
http://code.google.com/p/openid4java/issues/detail?id=15&can=1

Original comment by Francois...@gmail.com on 16 Jun 2009 at 2:57

GoogleCodeExporter commented 8 years ago
Why do you say that? I don't remember with OP it was (maybe Live) but the KV 
message
I got only parsed after I applied trim() to the string.

Original comment by andrefcruz on 16 Jun 2009 at 3:14

GoogleCodeExporter commented 8 years ago
2 years ago, i believed it was a issue and modified the ParameterList class (you
applied trim() to the string instead).
http://code.google.com/p/openid4java/issues/detail?id=15&can=1#c9

But it was not an issue, and the reason there is an exception with an extra new 
line
is because in the spec : "The line is terminated by a single newline"
Spec : http://openid.net/specs/openid-authentication-2_0.html#anchor4

I had this problem because I used println() instead of print() to print the 
key-value
form encoding response and an extra new line was added.

So you got this exception because your OP did this mistake.

Original comment by Francois...@gmail.com on 17 Jun 2009 at 9:12

GoogleCodeExporter commented 8 years ago
Yes, the OP is probably to blame here (I have to find out which one it was). I 
just
thought the extra trim wouldn't hurt if it meant working with more OPs.

Original comment by andrefcruz on 17 Jun 2009 at 9:22

GoogleCodeExporter commented 8 years ago
I'd shift this to a higher priority, I'm trying to use Google's OpenID endpoint 
at 
https://www.google.com/accounts/o8/id and it's displaying this behaviour. If 
there's a 
simple fix that makes this work in spite of broken servers please include it, I 
don't 
really want to have to fork yet another library because the authors have 
decided to 
follow a spec to the letter rather than deal with reality.

Original comment by tomo...@gmail.com on 20 Oct 2009 at 4:35

GoogleCodeExporter commented 8 years ago
Actually scratch my last comment - I was doing something brain dead (this 
happens when 
coding at five in the morning).

Original comment by tomo...@gmail.com on 20 Oct 2009 at 6:09

GoogleCodeExporter commented 8 years ago

Original comment by zhoushu...@gmail.com on 7 Jan 2011 at 8:21