JNec / sipservlets

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

Trailing '=' character added to flag parameters in URIs #170

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Set a flag parameter on an instance of URI by calling URI.setParameter() 
with a zero-length string as the value.
2. Use the URI in a request or print it out using toString().
3. Notice the trailing '=' after the parameter name.

What is the expected output? What do you see instead?
Flag parameters should be represented by the presence of their name only in the 
URI parameters (e.g. "tel:0123456;npdi"), however we are seeing 
"tel:0123456;npdi=".

What version of the product are you using? On what operating system?
MSS 1.7.0 on CentOS 5.8

Please provide any additional information below.
I have worked around the issue with the following code:

    public static void setURIFlagParameter(final URI requestURI, final String parameter) {
        // First set the parameter on the mobicents URI implementation.
        // A flag parameter is set by passing an empty string as the value.
        requestURI.setParameter(parameter, "");

        // Next workaround the bug by getting the parameters from the underlying
        // javax.sip.address.URI implementation and adding an explicitly-created
        // flag parameter (NameValue) to them.
        if (requestURI instanceof URIImpl) {
            NameValueList parameters = null;

            javax.sip.address.URI uri = ((URIImpl) requestURI).getURI();

            if (uri instanceof gov.nist.javax.sip.address.TelURLImpl) {
                parameters = ((gov.nist.javax.sip.address.TelURLImpl) uri).getParameters();
            }

            if (uri instanceof gov.nist.javax.sip.address.SipUri) {
                parameters = ((gov.nist.javax.sip.address.SipUri) uri).getParameters();
            }

            if (parameters != null) {
                // Create a NameValue with isFlag set to true
                parameters.set(new NameValue(parameter, "", true));
            }
        }
    }

Original issue reported on code.google.com by simon.sm...@telsis.com on 9 Oct 2012 at 8:37

GoogleCodeExporter commented 8 years ago

Original comment by jean.deruelle on 19 Oct 2012 at 11:18

GoogleCodeExporter commented 8 years ago

Original comment by jean.deruelle on 19 Oct 2012 at 11:18

GoogleCodeExporter commented 8 years ago

Original comment by jean.deruelle on 5 Jul 2013 at 7:44

GoogleCodeExporter commented 8 years ago
This issue was updated by revision 6f1185356a13.

Fix + non regression test

Original comment by jean.der...@telestax.com on 29 Apr 2014 at 4:49

GoogleCodeExporter commented 8 years ago

Original comment by jean.deruelle on 29 Apr 2014 at 4:52

GoogleCodeExporter commented 8 years ago

Original comment by jean.der...@telestax.com on 25 Aug 2014 at 10:52