Closed Bug 728636 Opened 9 years ago Closed 9 years ago

Conversion of email address to account should lowercase

Categories

(Firefox for Android Graveyard :: Android Sync, defect, P2)

ARM
Android
defect

Tracking

(Not tracked)

RESOLVED FIXED
mozilla13

People

(Reporter: rnewman, Assigned: rnewman)

Details

We only lowercase the output.

    public static String usernameFromAccount(String account) throws NoSuchAlgorithmException, UnsupportedEncodingException {
      if (account == null || account.equals("")) {
        throw new IllegalArgumentException("No account name provided.");
      }
      if (account.matches("^[A-Za-z0-9._-]+$")) {
        return account;
      }
      return Utils.sha1Base32(account);
    }

  public static byte[] sha1(String utf8)
      throws NoSuchAlgorithmException, UnsupportedEncodingException {
    MessageDigest sha1 = MessageDigest.getInstance("SHA-1");
    return sha1.digest(utf8.getBytes("UTF-8"));
  }

  public static String sha1Base32(String utf8)
      throws NoSuchAlgorithmException, UnsupportedEncodingException {
    return new Base32().encodeAsString(sha1(utf8)).toLowerCase();
  }

This, of course, will b0rk setup for anyone who capitalizes their email address (or whose Android keyboard does it for them).
https://hg.mozilla.org/integration/mozilla-inbound/rev/08df8cb41dfd
Assignee: nobody → rnewman
Status: NEW → ASSIGNED
https://hg.mozilla.org/mozilla-central/rev/08df8cb41dfd
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla13
Product: Mozilla Services → Android Background Services
Product: Android Background Services → Firefox for Android
Product: Firefox for Android → Firefox for Android Graveyard
You need to log in before you can comment on or make changes to this bug.