OSDN Git Service

Making it possible to call SIP calls with special allowed chars.
authorMagnus Strandberg <magnus.strandberg@sonyericsson.com>
Tue, 22 Mar 2011 07:03:58 +0000 (08:03 +0100)
committerJohan Redestig <johan.redestig@sonyericsson.com>
Tue, 22 Mar 2011 07:03:58 +0000 (08:03 +0100)
Since String.replaceFirst uses regex and since SIP user names are
allowed to include regex charaters such as '+', the code must
fist convert the string to a literal pattern String before using
replaceFirst method.

Change-Id: I25eac852bd620724ca1c5b2befc023af9dae3c1a

telephony/java/com/android/internal/telephony/sip/SipPhone.java [changed mode: 0755->0644]
voip/java/com/android/server/sip/SipHelper.java

old mode 100755 (executable)
new mode 100644 (file)
index 461e4fb..e37afda
@@ -41,6 +41,7 @@ import com.android.internal.telephony.UUSInfo;
 
 import java.text.ParseException;
 import java.util.List;
+import java.util.regex.Pattern;
 
 /**
  * {@hide}
@@ -383,8 +384,8 @@ public class SipPhone extends SipPhoneBase {
         Connection dial(String originalNumber) throws SipException {
             String calleeSipUri = originalNumber;
             if (!calleeSipUri.contains("@")) {
-                calleeSipUri = mProfile.getUriString().replaceFirst(
-                        mProfile.getUserName() + "@",
+                String replaceStr = Pattern.quote(mProfile.getUserName() + "@");
+                calleeSipUri = mProfile.getUriString().replaceFirst(replaceStr,
                         calleeSipUri + "@");
             }
             try {
index 518543a..f24e3fb 100644 (file)
@@ -27,6 +27,8 @@ import java.text.ParseException;
 import java.util.ArrayList;
 import java.util.EventObject;
 import java.util.List;
+import java.util.regex.Pattern;
+
 import javax.sip.ClientTransaction;
 import javax.sip.Dialog;
 import javax.sip.DialogTerminatedEvent;
@@ -215,9 +217,11 @@ class SipHelper {
             String tag) throws ParseException, SipException {
         FromHeader fromHeader = createFromHeader(userProfile, tag);
         ToHeader toHeader = createToHeader(userProfile);
+
+        String replaceStr = Pattern.quote(userProfile.getUserName() + "@");
         SipURI requestURI = mAddressFactory.createSipURI(
-                userProfile.getUriString().replaceFirst(
-                userProfile.getUserName() + "@", ""));
+                userProfile.getUriString().replaceFirst(replaceStr, ""));
+
         List<ViaHeader> viaHeaders = createViaHeaders();
         CallIdHeader callIdHeader = createCallIdHeader();
         CSeqHeader cSeqHeader = createCSeqHeader(requestType);