Closed Bug 724152 Opened 14 years ago Closed 14 years ago

Honor URL_SAFE flag for base64 encoding/decoding

Categories

(Firefox for Android Graveyard :: General, defect)

ARM
Android
defect
Not set
normal

Tracking

(firefox12 fixed)

RESOLVED FIXED
Firefox 13
Tracking Status
firefox12 --- fixed

People

(Reporter: bnicholson, Assigned: bnicholson)

Details

Attachments

(1 file, 1 obsolete file)

Attached patch patch (obsolete) — Splinter Review
With bug 723550, for Froyo and higher, we use the URL_SAFE flag for all base64 encodings, but we use the DEFAULT flag for decodings. There are a few problems with this: 1) encodeBase64 and decodeBase64 should be inverse functions such that X equals decodeBase64(encodeBase64(X)). This isn't true since we use a different set of flags for each operation. 2) The base64 implementation in GeckoAppShell, used in Eclair, always assumes URL_SAFE. I think this will break search engine icons in Eclair (though I don't have an Eclair device to test this with). This patch makes the base64 implementation in GeckoAppShell honor the URL_SAFE flag and requires callers to specify which encoding/decoding flags will be used.
Attachment #594344 - Flags: review?(blassey.bugs)
Attached patch patchSplinter Review
Fixed bug number/description in commit message.
Attachment #594344 - Attachment is obsolete: true
Attachment #594344 - Flags: review?(blassey.bugs)
Attachment #594353 - Flags: review?(blassey.bugs)
Comment on attachment 594353 [details] [diff] [review] patch Review of attachment 594353 [details] [diff] [review]: ----------------------------------------------------------------- ::: mobile/android/base/GeckoAppShell.java @@ +1861,5 @@ > for (int i=0; i<map2.length; i++) map2[i] = -1; > for (int i=0; i<64; i++) map2[map1[i]] = (byte)i; > + map2_urlsafe = map2.clone(); > + map2_urlsafe[map1_urlsafe[62]] = (byte)62; > + map2_urlsafe[map1_urlsafe[63]] = (byte)63; there is no need for two maps here @@ +1919,5 @@ > byte[] out = new byte[oLen]; > int ip = iOff; > int iEnd = iOff + iLen; > int op = 0; > + byte[] fromMap = ((flags & BASE64_URL_SAFE) == 0 ? map2 : map2_urlsafe); just use map2 (with the two additional entries) @@ +1930,5 @@ > throw new IllegalArgumentException ("Illegal character in Base64 encoded data."); > + int b0 = fromMap[i0]; > + int b1 = fromMap[i1]; > + int b2 = fromMap[i2]; > + int b3 = fromMap[i3]; again, just map2
Attachment #594353 - Flags: review?(blassey.bugs) → review+
Comment on attachment 594353 [details] [diff] [review] patch [Approval Request Comment] Makes base64 API consistent for encoding/decoding and for Eclair/post-Eclair. Low risk.
Attachment #594353 - Flags: approval-mozilla-beta?
Attachment #594353 - Flags: approval-mozilla-aurora?
Status: NEW → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 13
Comment on attachment 594353 [details] [diff] [review] patch [Triage Comment] Mobile only - approved for Aurora 12 and Beta 11.
Attachment #594353 - Flags: approval-mozilla-beta?
Attachment #594353 - Flags: approval-mozilla-beta+
Attachment #594353 - Flags: approval-mozilla-aurora?
Attachment #594353 - Flags: approval-mozilla-aurora+
FYI was going to help clear the queue here: Justin@ORION /d/sources/mozilla-beta $ hg qpush applying base64.patch patching file mobile/android/base/GeckoAppShell.java Hunk #1 FAILED at 1828 1 out of 1 hunks FAILED -- saving rejects to file mobile/android/base/GeckoAppShell.java.rej patch failed, unable to continue (try -v) patch failed, rejects left in working dir errors during apply, please fix and refresh base64.patch
Comment on attachment 594353 [details] [diff] [review] patch Clearing approval for Aurora 12 and Beta 11 because we are not currently planning a Native Fennec release of these versions. If this changes in the future, we will likely do a mass uplift of all native fennec changes. For now, let's get these bugs off the channel triage radar. [Filter on the string "mbrubeck-bugspam" if you want to delete all of these emails at once.]
Attachment #594353 - Flags: approval-mozilla-beta+
Attachment #594353 - Flags: approval-mozilla-aurora+
Whiteboard: [qa-]
Whiteboard: [qa-]
Product: Firefox for Android → Firefox for Android Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: