package org.openqa.selenium.server;

public class BrowserConfigurationOptions {

    private String profile = "";
    
    public BrowserConfigurationOptions(String browserConfiguration) {
        //"name:value;name:value"
        String[] optionsPairList = browserConfiguration.split(";");
        for (int i = 0; i < optionsPairList.length; i++) {
            String[] option = optionsPairList[i].split(":", 2);
            String optionsName = option[0].trim();
            String optionValue = option[1].trim();
            if ("profile".equalsIgnoreCase(optionsName)) {
                this.profile = optionValue;
            }
        }
    }
    
    public BrowserConfigurationOptions() {}

    /**
     * Sets the profile name for this configuration object.
     * @param profile_name  The name of the profile to use
     */
    public void setProfile(String profile_name) {
        this.profile = profile_name;
    }
    
    public String serialize() {
        //"profile:XXXXXXXXXX"
        return String.format("profile:%s", profile);
    }

    public String getProfile() {
        return profile;
    }

}

@@ -407,16 +407,56 @@
 :%22, 2);%0A
+            if (2 == option.length) %7B%0A  
         
@@ -490,32 +490,34 @@
 tion%5B0%5D.trim();%0A
+  
             Stri
@@ -559,24 +559,26 @@
             
+ 
+ 
 if (%22profile
@@ -620,32 +620,34 @@
                 
+  
 this.profile = o
@@ -658,16 +658,32 @@
 nValue;%0A
+              %7D%0A
         

Fix index out of bounds exception by first checking to make sure the configuration option parsed correctly.