Android OS Forum banner
1 - 1 of 1 Posts

·
Developer
Joined
·
111 Posts
HowTo To Teach Email Proper Contractions

I realize this is fixed in 4.0.4 but the source is not out yet and this was really bugging me. Basically, many of you may be familiar with this famous bug in the Email app from Honeycomb: http://code.google.c...detail?id=16873 Essentially, if you send an email from the stock Android Email app and used any one if a handful of characters (<>&\"), the recipient received the email but those specific characters where encoded incorrectly.

You would see:
Code:
<br />
that&amp;s ridiculous!<br />
Instead of:
Code:
<br />
that's ridiculous!<br />
It took forever it seemed, but Google fixed the issue in the release of 3.2. However, they inadvertently released the bug back into Android in 4.0. Amazing really, but I can only imagine how this happened. If you are curious, here is the link to the new issue: http://code.google.c...detail?id=24580

Apparently, it is fixed in a future release, but that does not help anyone who does not have access to 4.0.4. The fix is relatively easy to do. If you compile your own source, you can have this fixed in minutes. It only requires two edits and a handful of code.

First find the method htmlEncode in /frameworks/base/core/java/android/text/TextUtils.java and paste the following code below it:
Code:
<br />
<br />
	/**<br />
	 * Google fixed this in 3.2 and then broke it again in 4.x<br />
	 * @param s<br />
	 * @return<br />
	 */<br />
	public static String htmlEncodeForEmail(String s) {<br />
		StringBuilder sb = new StringBuilder();<br />
		char c;<br />
		for (int i = 0; i < s.length(); i++) {<br />
			c = s.charAt(i);<br />
			switch (c) {<br />
			case '<':<br />
				sb.append("&#60;"); //$NON-NLS-1$<br />
				break;<br />
			case '>':<br />
				sb.append("&#62;"); //$NON-NLS-1$<br />
				break;<br />
			case '&':<br />
				sb.append("&#38;"); //$NON-NLS-1$<br />
				break;<br />
			case '\'':<br />
				sb.append("&#39;"); //$NON-NLS-1$<br />
				break;<br />
			case '"':<br />
				sb.append("&#34;"); //$NON-NLS-1$<br />
				break;<br />
			default:<br />
				sb.append(c);<br />
			}<br />
		}<br />
		return sb.toString();<br />
	}<br />
Next make this small easy change in /packages/apps/Email/emailcommon/src/com/android/emailcommon/internet/Rfc822Output.java:
 
1 - 1 of 1 Posts
Top