Assigned
Status Update
Comments
ra...@google.com <ra...@google.com> #2
We have shared this with our product and engineering team and will update this issue with more information as it becomes available.
ma...@gmail.com <ma...@gmail.com> #3
Thanks for your request. We will investigate this issue and see if we can implement the behavior you've requested.
Description
Source file:
The message body is read with the function reader.getLineEnforce(), this
function removes <CR><LN>.
Since <CR><LN> is used to split both headers and Mime parts inside the
MSG body that will not work.
Tested on Google Pixel 7a with Android 13 and 15 also verified by inspection of above source.
Can be verified by encoding a message and then decoding it using the functions in above source.
Correct Behaviour:
A GetLineEnforceNoStrip function should be used which leaves the MSG body intact,
while reading line for line. Also check for "END:MSG\r\n" instead of "END:MSG".
Suggestion for correction of Code that reads message Body:
// Read until we receive END:MSG as some carkits send bad message lengths
while (!messageLine.equals("END:MSG\r\n")) {
data.append(messageLine);
messageLine = reader.getLineEnforceNoStrip();
}
// Leave <CR> and <LN> untouched. Also leave empty lines since <CR><LN> and <CR><LN><CR><LN> is used for splitting
private byte[] getLineAsBytesNoStrip() {
int readByte;
/* TODO: Actually the vCard spec. allows to break lines by using a newLine
* followed by a white space character(space or tab). Not sure this is a good idea to
* implement as the Bluetooth MAP spec. illustrates vCards using tab alignment,
* hence actually showing an invalid vCard format...
* If we read such a folded line, the folded part will be skipped in the parser
* UPDATE: Check if we actually do unfold before parsing the input stream
*/
ByteArrayOutputStream output = new ByteArrayOutputStream();
try {
while ((readByte = mInStream.read()) != -1) {
if (readByte == '\r') {
if ((readByte = mInStream.read()) != -1 && readByte == '\n') {
// End of line (\r\n) found, break
output.write('\r');
output.write(readByte);
break;
} else {
output.write('\r');
}
}
output.write(readByte);
}
} catch (IOException e) {
System.out.println("getLineAsBytes, Error:"+ e);
return null;
}
return output.toByteArray();
}