if ((((uint8*)submit->type_array)[i] == FORM_TYPE_PASSWORD) && (((submit->value_array)) [i]).Length == 0 ) {
if (((uint8*)submit->type_array)[i] == FORM_TYPE_PASSWORD) if (((submit->value_array) [i]).Length() == 0 ) {
si_PutData(char * URLName, si_FormSubmitData * submit, PRBool save) {  PRBool added_to_list = PR_FALSE;  si_SignonURLStruct * url;  si_SignonUserStruct * user;  si_SignonDataStruct * data;  PRBool mismatch;  /* discard this if the password is empty */  for (PRInt32 i=0; i<submit->value_cnt; i++) {    if ((((uint8*)submit->type_array)[i] == FORM_TYPE_PASSWORD) &&        (((submit->value_array)) [i]).Length == 0 ) {      return;    }  }  /*   * lock the signon list   *   Note that, for efficiency, SI_LoadSignonData already sets the lock   *   before calling this routine whereas none of the other callers do.   *   So we need to determine whether or not we were called from   *   SI_LoadSignonData before setting or clearing the lock.  We can   *   determine this by testing "save" since only SI_LoadSignonData passes   *   in a value of PR_FALSE for "save".   */  if (save) {    si_lock_signon_list();  }  /* make sure the signon list exists */  if(!si_signon_list) {    si_signon_list = new nsVoidArray();    if(!si_signon_list) {      if (save) {        si_unlock_signon_list();      }      return;    }  }  /* find node in signon list having the same URL */  if ((url = si_GetURL(URLName)) == NULL) {    /* doesn't exist so allocate new node to be put into signon list */    url = new si_SignonURLStruct;    if (!url) {      if (save) {        si_unlock_signon_list();      }      return;    }    /* fill in fields of new node */    url->URLName = si_StrippedURL(URLName);    if (!url->URLName) {      PR_Free(url);      if (save) {        si_unlock_signon_list();      }      return;    }    url->signonUser_list = new nsVoidArray();    if(!url->signonUser_list) {      PR_Free(url->URLName);      PR_Free(url);    }    /* put new node into signon list */#ifdef alphabetize    /* add it to the list in alphabetical order */    si_SignonURLStruct * tmp_URL;    PRInt32 urlCount = LIST_COUNT(si_signon_list);    for (PRInt32 ii = 0; ii<urlCount; ++ii) {      tmp_URL = NS_STATIC_CAST(si_SignonURLStruct *, si_signon_list->ElementAt(ii));      if (tmp_URL) {        if (PL_strcasecmp(url->URLName, tmp_URL->URLName)<0) {          si_signon_list->InsertElementAt(url, ii);          added_to_list = PR_TRUE;          break;        }      }    }    if (!added_to_list) {      si_signon_list->AppendElement(url);    }#else    /* add it to the end of the list */    si_signon_list->AppendElement(url);#endif  }  /* initialize state variables in URL node */  url->chosen_user = NULL;  /*   * see if a user node with data list matching new data already exists   * (password fields will not be checked for in this matching)   */  PRInt32 userCount = LIST_COUNT(url->signonUser_list);  for (PRInt32 i2=0; i2<userCount; i2++) {    user = NS_STATIC_CAST(si_SignonUserStruct*, url->signonUser_list->ElementAt(i2));    PRInt32 j = 0;    PRInt32 dataCount = LIST_COUNT(user->signonData_list);    for (PRInt32 i3=0; i3<dataCount; i3++) {      data = NS_STATIC_CAST(si_SignonDataStruct*, user->signonData_list->ElementAt(i3));      mismatch = PR_FALSE;      /* skip non text/password fields */      while ((j < submit->value_cnt) &&            (((uint8*)submit->type_array)[j]!=FORM_TYPE_TEXT) &&            (((uint8*)submit->type_array)[j]!=FORM_TYPE_PASSWORD)) {        j++;      }      /* check for match on name field and type field */      if ((j < submit->value_cnt) &&          (data->isPassword ==            (((uint8*)submit->type_array)[j]==FORM_TYPE_PASSWORD)) &&            (data->name == (submit->name_array)[j])) {        /* success, now check for match on value field if not password */        if (data->value == (submit->value_array)[j] || data->isPassword) {          j++; /* success */        } else {          mismatch = PR_TRUE;          break; /* value mismatch, try next user */        }      } else {        mismatch = PR_TRUE;        break; /* name or type mismatch, try next user */      }    }    if (!mismatch) {      /* all names and types matched and all non-password values matched */      /*       * note: it is ok for password values not to match; it means       * that the user has either changed his password behind our       * back or that he previously mis-entered the password       */      /* update the saved password values */      j = 0;      PRInt32 dataCount2 = LIST_COUNT(user->signonData_list);      for (PRInt32 i4=0; i4<dataCount2; i4++) {        data = NS_STATIC_CAST(si_SignonDataStruct*, user->signonData_list->ElementAt(i4));        /* skip non text/password fields */        while ((j < submit->value_cnt) &&              (((uint8*)submit->type_array)[j]!=FORM_TYPE_TEXT) &&              (((uint8*)submit->type_array)[j]!=FORM_TYPE_PASSWORD)) {          j++;        }        /* update saved password */        if ((j < submit->value_cnt) && data->isPassword) {          if (data->value != (submit->value_array)[j]) {            si_signon_list_changed = PR_TRUE;            data->value = (submit->value_array)[j];            si_Randomize(data->value);          }        }        j++;      }      /*       * since this user node is now the most-recently-used one, move it       * to the head of the user list so that it can be favored for       * re-use the next time this form is encountered       */      url->signonUser_list->RemoveElement(user);      url->signonUser_list->InsertElementAt(user, 0);      /* return */      if (save) {        si_signon_list_changed = PR_TRUE;        si_SaveSignonDataLocked(PR_TRUE);        si_unlock_signon_list();      }      return; /* nothing more to do since data already exists */    }  }  /* user node with current data not found so create one */  user = new si_SignonUserStruct;  if (!user) {    if (save) {      si_unlock_signon_list();    }    return;  }  user->signonData_list = new nsVoidArray();  if(!user->signonData_list) {    PR_Free(user);    if (save) {      si_unlock_signon_list();    }    return;  }  /* create and fill in data nodes for new user node */  for (PRInt32 k=0; k<submit->value_cnt; k++) {    /* skip non text/password fields */    if((((uint8*)submit->type_array)[k]!=FORM_TYPE_TEXT) &&        (((uint8*)submit->type_array)[k]!=FORM_TYPE_PASSWORD)) {      continue;    }    /* create signon data node */    data = new si_SignonDataStruct;    if (!data) {      delete user->signonData_list;      PR_Free(user);      if (save) {        si_unlock_signon_list();      }      return;    }    data->isPassword = (((uint8 *)submit->type_array)[k] == FORM_TYPE_PASSWORD);    data->name = (submit->name_array)[k];    data->value = (submit->value_array)[k];    if (data->isPassword) {      si_Randomize(data->value);    }    /* append new data node to end of data list */    user->signonData_list->AppendElement(data);  }  /* append new user node to front of user list for matching URL */    /*     * Note that by appending to the front, we assure that if there are     * several users, the most recently used one will be favored for     * reuse the next time this form is encountered.  But don't do this     * when reading in signons.txt (i.e., when save is PR_FALSE), otherwise     * we will be reversing the order when reading in.     */  if (save) {    url->signonUser_list->InsertElementAt(user, 0);    si_signon_list_changed = PR_TRUE;    si_SaveSignonDataLocked(PR_TRUE);    if (!si_KeySet()) {      url->signonUser_list->RemoveElementAt(0);    }    si_unlock_signon_list();  } else {    url->signonUser_list->AppendElement(user);  }}