Program: 195791
Project: 195791
Buggy source:
/** 
 * Create an intent from a URI.  This URI may encode the action, category, and other intent fields, if it was returned by  {@link #toUri}.  If the Intent was not generate by toUri(), its data will be the entire URI and its action will be ACTION_VIEW. <p>The URI given here must not be relative -- that is, it must include the scheme and full path.
 * @param uri The URI to turn into an Intent.
 * @param flags Additional processing flags.  Either 0,{@link #URI_INTENT_SCHEME}, or   {@link #URI_ANDROID_APP_SCHEME}.
 * @return Intent The newly created Intent object.
 * @throws URISyntaxException Throws URISyntaxError if the basic URI syntaxit bad (as parsed by the Uri class) or the Intent data within the URI is invalid.
 * @see #toUri
 */
public static Intent parseUri(String uri,int flags) throws URISyntaxException {
  int i=0;
  try {
    final boolean androidApp=uri.startsWith("String_Node_Str");
    if ((flags & (URI_INTENT_SCHEME | URI_ANDROID_APP_SCHEME)) != 0) {
      if (!uri.startsWith("String_Node_Str") && !androidApp) {
        Intent intent=new Intent(ACTION_VIEW);
        try {
          intent.setData(Uri.parse(uri));
        }
 catch (        IllegalArgumentException e) {
          throw new URISyntaxException(uri,e.getMessage());
        }
        return intent;
      }
    }
    i=uri.lastIndexOf("String_Node_Str");
    if (i == -1) {
      if (!androidApp) {
        return new Intent(ACTION_VIEW,Uri.parse(uri));
      }
    }
 else     if (!uri.startsWith("String_Node_Str",i)) {
      if (!androidApp) {
        return getIntentOld(uri,flags);
      }
 else {
        i=-1;
      }
    }
    Intent intent=new Intent(ACTION_VIEW);
    Intent baseIntent=intent;
    boolean explicitAction=false;
    boolean inSelector=false;
    String scheme=null;
    String data;
    if (i >= 0) {
      data=uri.substring(0,i);
      i+=8;
    }
 else {
      data=uri;
    }
    while (i >= 0 && !uri.startsWith("String_Node_Str",i)) {
      int eq=uri.indexOf('=',i);
      if (eq < 0)       eq=i - 1;
      int semi=uri.indexOf(';',i);
      String value=eq < semi ? Uri.decode(uri.substring(eq + 1,semi)) : "String_Node_Str";
      if (uri.startsWith("String_Node_Str",i)) {
        intent.setAction(value);
        if (!inSelector) {
          explicitAction=true;
        }
      }
 else       if (uri.startsWith("String_Node_Str",i)) {
        intent.addCategory(value);
      }
 else       if (uri.startsWith("String_Node_Str",i)) {
        intent.mType=value;
      }
 else       if (uri.startsWith("String_Node_Str",i)) {
        intent.mFlags=Integer.decode(value).intValue();
        if ((flags & URI_ALLOW_UNSAFE) == 0) {
          intent.mFlags&=~IMMUTABLE_FLAGS;
        }
      }
 else       if (uri.startsWith("String_Node_Str",i)) {
        intent.mPackage=value;
      }
 else       if (uri.startsWith("String_Node_Str",i)) {
        intent.mComponent=ComponentName.unflattenFromString(value);
      }
 else       if (uri.startsWith("String_Node_Str",i)) {
        if (inSelector) {
          intent.mData=Uri.parse(value);
        }
 else {
          scheme=value;
        }
      }
 else       if (uri.startsWith("String_Node_Str",i)) {
        intent.mSourceBounds=Rect.unflattenFromString(value);
      }
 else       if (semi == (i + 3) && uri.startsWith("String_Node_Str",i)) {
        intent=new Intent();
        inSelector=true;
      }
 else {
        String key=Uri.decode(uri.substring(i + 2,eq));
        if (intent.mExtras == null)         intent.mExtras=new Bundle();
        Bundle b=intent.mExtras;
        if (uri.startsWith("String_Node_Str",i))         b.putString(key,value);
 else         if (uri.startsWith("String_Node_Str",i))         b.putBoolean(key,Boolean.parseBoolean(value));
 else         if (uri.startsWith("String_Node_Str",i))         b.putByte(key,Byte.parseByte(value));
 else         if (uri.startsWith("String_Node_Str",i))         b.putChar(key,value.charAt(0));
 else         if (uri.startsWith("String_Node_Str",i))         b.putDouble(key,Double.parseDouble(value));
 else         if (uri.startsWith("String_Node_Str",i))         b.putFloat(key,Float.parseFloat(value));
 else         if (uri.startsWith("String_Node_Str",i))         b.putInt(key,Integer.parseInt(value));
 else         if (uri.startsWith("String_Node_Str",i))         b.putLong(key,Long.parseLong(value));
 else         if (uri.startsWith("String_Node_Str",i))         b.putShort(key,Short.parseShort(value));
 else         throw new URISyntaxException(uri,"String_Node_Str",i);
      }
      i=semi + 1;
    }
    if (inSelector) {
      if (baseIntent.mPackage == null) {
        baseIntent.setSelector(intent);
      }
      intent=baseIntent;
    }
    if (data != null) {
      if (data.startsWith("String_Node_Str")) {
        data=data.substring(7);
        if (scheme != null) {
          data=scheme + ':' + data;
        }
      }
 else       if (data.startsWith("String_Node_Str")) {
        if (data.charAt(12) == '/' && data.charAt(13) == '/') {
          int end=data.indexOf('/',14);
          if (end < 0) {
            intent.mPackage=data.substring(14);
            if (!explicitAction) {
              intent.setAction(ACTION_MAIN);
            }
            data="String_Node_Str";
          }
 else {
            String authority=null;
            intent.mPackage=data.substring(14,end);
            int newEnd;
            if (end < data.length() && (newEnd=data.indexOf('/',end + 1)) >= 0) {
              scheme=data.substring(end + 1,newEnd);
              end=newEnd;
              if (end < data.length() && (newEnd=data.indexOf('/',end + 1)) >= 0) {
                authority=data.substring(end + 1,newEnd);
                end=newEnd;
              }
            }
            if (scheme == null) {
              if (!explicitAction) {
                intent.setAction(ACTION_MAIN);
              }
              data="String_Node_Str";
            }
 else             if (authority == null) {
              data=scheme + "String_Node_Str";
            }
 else {
              data=scheme + "String_Node_Str" + authority+ data.substring(end);
            }
          }
        }
 else {
          data="String_Node_Str";
        }
      }
      if (data.length() > 0) {
        try {
          intent.mData=Uri.parse(data);
        }
 catch (        IllegalArgumentException e) {
          throw new URISyntaxException(uri,e.getMessage());
        }
      }
    }
    return intent;
  }
 catch (  IndexOutOfBoundsException e) {
    throw new URISyntaxException(uri,"String_Node_Str",i);
  }
}

Fixed version (ground truth):
/** 
 * Create an intent from a URI.  This URI may encode the action, category, and other intent fields, if it was returned by  {@link #toUri}.  If the Intent was not generate by toUri(), its data will be the entire URI and its action will be ACTION_VIEW. <p>The URI given here must not be relative -- that is, it must include the scheme and full path.
 * @param uri The URI to turn into an Intent.
 * @param flags Additional processing flags.  Either 0,{@link #URI_INTENT_SCHEME}, or   {@link #URI_ANDROID_APP_SCHEME}.
 * @return Intent The newly created Intent object.
 * @throws URISyntaxException Throws URISyntaxError if the basic URI syntaxit bad (as parsed by the Uri class) or the Intent data within the URI is invalid.
 * @see #toUri
 */
public static Intent parseUri(String uri,int flags) throws URISyntaxException {
  int i=0;
  try {
    final boolean androidApp=uri.startsWith("String_Node_Str");
    if ((flags & (URI_INTENT_SCHEME | URI_ANDROID_APP_SCHEME)) != 0) {
      if (!uri.startsWith("String_Node_Str") && !androidApp) {
        Intent intent=new Intent(ACTION_VIEW);
        try {
          intent.setData(Uri.parse(uri));
        }
 catch (        IllegalArgumentException e) {
          throw new URISyntaxException(uri,e.getMessage());
        }
        return intent;
      }
    }
    i=uri.lastIndexOf("String_Node_Str");
    if (i == -1) {
      if (!androidApp) {
        return new Intent(ACTION_VIEW,Uri.parse(uri));
      }
    }
 else     if (!uri.startsWith("String_Node_Str",i)) {
      if (!androidApp) {
        return getIntentOld(uri,flags);
      }
 else {
        i=-1;
      }
    }
    Intent intent=new Intent(ACTION_VIEW);
    Intent baseIntent=intent;
    boolean explicitAction=false;
    boolean inSelector=false;
    String scheme=null;
    String data;
    if (i >= 0) {
      data=uri.substring(0,i);
      i+=8;
    }
 else {
      data=uri;
    }
    while (i >= 0 && !uri.startsWith("String_Node_Str",i)) {
      int eq=uri.indexOf('=',i);
      if (eq < 0)       eq=i - 1;
      int semi=uri.indexOf(';',i);
      String value=eq < semi ? Uri.decode(uri.substring(eq + 1,semi)) : "String_Node_Str";
      if (uri.startsWith("String_Node_Str",i)) {
        intent.setAction(value);
        if (!inSelector) {
          explicitAction=true;
        }
      }
 else       if (uri.startsWith("String_Node_Str",i)) {
        intent.addCategory(value);
      }
 else       if (uri.startsWith("String_Node_Str",i)) {
        intent.mType=value;
      }
 else       if (uri.startsWith("String_Node_Str",i)) {
        intent.mFlags=Integer.decode(value).intValue();
        if ((flags & URI_ALLOW_UNSAFE) == 0) {
          intent.mFlags&=~IMMUTABLE_FLAGS;
        }
      }
 else       if (uri.startsWith("String_Node_Str",i)) {
        intent.mPackage=value;
      }
 else       if (uri.startsWith("String_Node_Str",i)) {
        intent.mComponent=ComponentName.unflattenFromString(value);
      }
 else       if (uri.startsWith("String_Node_Str",i)) {
        if (inSelector) {
          intent.mData=Uri.parse(value + "String_Node_Str");
        }
 else {
          scheme=value;
        }
      }
 else       if (uri.startsWith("String_Node_Str",i)) {
        intent.mSourceBounds=Rect.unflattenFromString(value);
      }
 else       if (semi == (i + 3) && uri.startsWith("String_Node_Str",i)) {
        intent=new Intent();
        inSelector=true;
      }
 else {
        String key=Uri.decode(uri.substring(i + 2,eq));
        if (intent.mExtras == null)         intent.mExtras=new Bundle();
        Bundle b=intent.mExtras;
        if (uri.startsWith("String_Node_Str",i))         b.putString(key,value);
 else         if (uri.startsWith("String_Node_Str",i))         b.putBoolean(key,Boolean.parseBoolean(value));
 else         if (uri.startsWith("String_Node_Str",i))         b.putByte(key,Byte.parseByte(value));
 else         if (uri.startsWith("String_Node_Str",i))         b.putChar(key,value.charAt(0));
 else         if (uri.startsWith("String_Node_Str",i))         b.putDouble(key,Double.parseDouble(value));
 else         if (uri.startsWith("String_Node_Str",i))         b.putFloat(key,Float.parseFloat(value));
 else         if (uri.startsWith("String_Node_Str",i))         b.putInt(key,Integer.parseInt(value));
 else         if (uri.startsWith("String_Node_Str",i))         b.putLong(key,Long.parseLong(value));
 else         if (uri.startsWith("String_Node_Str",i))         b.putShort(key,Short.parseShort(value));
 else         throw new URISyntaxException(uri,"String_Node_Str",i);
      }
      i=semi + 1;
    }
    if (inSelector) {
      if (baseIntent.mPackage == null) {
        baseIntent.setSelector(intent);
      }
      intent=baseIntent;
    }
    if (data != null) {
      if (data.startsWith("String_Node_Str")) {
        data=data.substring(7);
        if (scheme != null) {
          data=scheme + ':' + data;
        }
      }
 else       if (data.startsWith("String_Node_Str")) {
        if (data.charAt(12) == '/' && data.charAt(13) == '/') {
          int end=data.indexOf('/',14);
          if (end < 0) {
            intent.mPackage=data.substring(14);
            if (!explicitAction) {
              intent.setAction(ACTION_MAIN);
            }
            data="String_Node_Str";
          }
 else {
            String authority=null;
            intent.mPackage=data.substring(14,end);
            int newEnd;
            if ((end + 1) < data.length()) {
              if ((newEnd=data.indexOf('/',end + 1)) >= 0) {
                scheme=data.substring(end + 1,newEnd);
                end=newEnd;
                if (end < data.length() && (newEnd=data.indexOf('/',end + 1)) >= 0) {
                  authority=data.substring(end + 1,newEnd);
                  end=newEnd;
                }
              }
 else {
                scheme=data.substring(end + 1);
              }
            }
            if (scheme == null) {
              if (!explicitAction) {
                intent.setAction(ACTION_MAIN);
              }
              data="String_Node_Str";
            }
 else             if (authority == null) {
              data=scheme + "String_Node_Str";
            }
 else {
              data=scheme + "String_Node_Str" + authority+ data.substring(end);
            }
          }
        }
 else {
          data="String_Node_Str";
        }
      }
      if (data.length() > 0) {
        try {
          intent.mData=Uri.parse(data);
        }
 catch (        IllegalArgumentException e) {
          throw new URISyntaxException(uri,e.getMessage());
        }
      }
    }
    return intent;
  }
 catch (  IndexOutOfBoundsException e) {
    throw new URISyntaxException(uri,"String_Node_Str",i);
  }
}