Skip navigation
2647 Views 19 Replies Latest reply: Jun 30, 2011 5:56 PM by Antony RSS
Antony Bronze 65 posts since
May 29, 2011
Currently Being Moderated

Jun 23, 2011 1:50 AM

XEP-147 (URI scheme) not working with 8 bit chars

Wolf_P,

 

Thanks for making those changes for this.  We've tried this, but it seems it does not handle 8 bit characters properly

 

We have a roster URI, which is 

...roster;name=%C3%84%C3%A4kk%C3%B6nen%20%C3%96ky

 

This represents the name "Ääkkönen Öky" and it is utf-8 encoded and then pct-encoded.  This follows step 2 of section 3.1 of RFC 3987, which states

 

Step 2.  For each character in 'ucschar' or 'iprivate', apply steps

            2.1 through 2.3 below.

 

       2.1.  Convert the character to a sequence of one or more octets

             using UTF-8 [RFC3629].

 

       2.2.  Convert each octet to %HH, where HH is the hexadecimal

             notation of the octet value.  Note that this is identical

             to the percent-encoding mechanism in section 2.1 of
             [RFC3986]
.  To reduce variability, the hexadecimal notation

             SHOULD use uppercase letters.

 

       2.3.  Replace the original character with the resulting character

             sequence (i.e., a sequence of %HH triplets).

 

If the data is sent with no utf-8 encoding, i.e. the 8 bit characters are sent as is, then the name will appear in the Nickname.

 

The %20 is decoded to a space.  Looking at UriIManager, it does not do any decoding of the String apart from the call to replace for the %20 encoding. 

 

I am not sure of the fix for this as I don't know how the command line parameters are handled, but from my reading of the RFC, all the URI mapping handlers should actually be treating the Java uriMapping String as a pct-encoded utf-8 byte stream, so they should be doing something like

 

a) Decode pct-encoding to byte

b) Create byte array from command line including decoded bytes

c) Create java String from byte array with new String (byte[], Charset.forName("UTF-8"));

 

Do you agree?

Antony

  • Wolf Gold 278 posts since
    Feb 5, 2011
    Currently Being Moderated
    Jun 23, 2011 2:23 AM (in response to Antony)
    Re: XEP-147 (URI scheme) not working with 8 bit chars

    you should post a patch

     

     

    also it shouldnt work for the other commands, because they dont convert 8bit chars either

        • Walter Ebeling KeyContributor 689 posts since
          Oct 25, 2006
          Currently Being Moderated
          Jun 27, 2011 11:00 PM (in response to Antony)
          Re: XEP-147 (URI scheme) not working with 8 bit chars

          I'll ask Wolf to take a look into it. We have tentatively scheduled XEP 147 into the next release 2.6.3 that will go this week (or will be delayed for 8 -12 weeks).

            • Wolf Gold 278 posts since
              Feb 5, 2011
              Currently Being Moderated
              Jun 28, 2011 1:20 PM (in response to Antony)
              Re: XEP-147 (URI scheme) not working with 8 bit chars

              Completed: At revision: 12546 

               

              thank you for submitting

               

              Can you please check the nightly at http://bamboo.igniterealtime.org/browse/SPARK and report the result?

            • Walter Ebeling KeyContributor 689 posts since
              Oct 25, 2006
              Currently Being Moderated
              Jun 29, 2011 1:37 PM (in response to Antony)
              Re: XEP-147 (URI scheme) not working with 8 bit chars

              Please report test results.

                • Wolf Gold 278 posts since
                  Feb 5, 2011
                  Currently Being Moderated
                  Jun 30, 2011 12:53 AM (in response to Antony)
                  Re: XEP-147 (URI scheme) not working with 8 bit chars

                  when starting eclipse from windows you can remove the following sources:

                  - apple

                  - growl

                  - linux

                   

                  same goes when starting from apple you will need to remove:

                  - linux

                   

                  on linux remove:

                  - apple

                  - growl

                   

                   

                   

                  ----------------

                   

                  please post patches not whole source files

                    • Wolf Gold 278 posts since
                      Feb 5, 2011
                      Currently Being Moderated
                      Jun 30, 2011 2:26 AM (in response to Antony)
                      Re: XEP-147 (URI scheme) not working with 8 bit chars

                      from commandline:

                      svn diff sparkfolder > somename.patch

                       

                      from whatever your client is:

                      google

                        • Wolf Gold 278 posts since
                          Feb 5, 2011
                          Currently Being Moderated
                          Jun 30, 2011 2:43 AM (in response to Antony)
                          Re: XEP-147 (URI scheme) not working with 8 bit chars

                          try this in URIManager.java line #128

                           

                          jid= jid.contains("/")&&jid.lastIndexOf("/")==jid.length()-1 ? jid.substring(0,jid.length()-1):jid;

                            • Wolf Gold 278 posts since
                              Feb 5, 2011
                              Currently Being Moderated
                              Jun 30, 2011 4:10 AM (in response to Antony)
                              Re: XEP-147 (URI scheme) not working with 8 bit chars

                              Antony schrieb:

                               

                              I check that path is not / in retrieveJid().  Sensible change, but still not clear where that / is coming from in the failure case.

                               

                              Index: src/java/org/jivesoftware/spark/uri/UriManager.java
                              ===================================================================
                              --- src/java/org/jivesoftware/spark/uri/UriManager.java    (revision 12554)
                              +++ src/java/org/jivesoftware/spark/uri/UriManager.java    (working copy)
                              @@ -233,7 +233,8 @@
                                   sb.append(uri.getHost());
                                   // Resource contains the leading /
                                   String resource = uri.getPath();
                              -    if (resource != null && resource != "") {
                              +    
                              +    if (resource != null && resource.length() > 0 && !resource.equals("/")) {
                                       sb.append(resource);
                                   }
                                   return sb.toString();
                              

                               

                              Ha!  Now I can make patches

                               

                              Does this work now? cannot test at this moment

  • Wolf Gold 278 posts since
    Feb 5, 2011
    Currently Being Moderated
    Jun 30, 2011 10:39 AM (in response to Antony)
    XEP-147 (URI scheme) not working with 8 bit chars

    ant -f sparksourcefolder/build/build.xml jar

     

    cp sparksourcefolder/target/build/lib/spark.jar yousparkinstallfolder/lib/spark.jar

     

    you dont need to build an exe, the spark.jar file is enough

More Like This

  • Retrieving data ...

Bookmarked By (0)

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points