Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c11180a6 authored by Ashwini Munigala's avatar Ashwini Munigala Committed by Linux Build Service Account
Browse files

MAP: Parse last occurence of "END:BBODY" in BMessage.

Allow pushMessage email with multiple "ENG:BBODY" tags
in email body message. Parse till last occurence of
END:BBODY to retreive the actual email text body.

Remove a '/' for all occurrences of <CRLF>'/END:MSG'.

CRs-Fixed: 912765
Change-Id: I2d65454c0dcbbf263fe80cc09e1240d3427be2d4
parent 5e22b4a3
Loading
Loading
Loading
Loading
+36 −4
Original line number Diff line number Diff line
@@ -513,7 +513,34 @@ public abstract class BluetoothMapbMessage {
            }
            return data;
        }

        /**
         * Read a part of BMessage including empty lines for last occurence of  terminator
         * @return the string till terminator, or null at end of file, or if UTF-8 is not supported
         * @hide
         */
        public String getLastStringTerminator(String terminator) {
            StringBuilder dataStr = new StringBuilder();
            String lineCur = getLineTerminator();
            while ( lineCur != null ) {
                String firstOccur = getStringTerminator(terminator);
                if (firstOccur != null ) {
                    if (dataStr.length() != 0 ) {
                        dataStr.append(terminator);
                        dataStr.append("\r\n");
                    }
                    dataStr.append(lineCur);
                    if (!lineCur.equals("\r\n")) {
                        dataStr.append("\r\n");
                    }
                    dataStr.append(firstOccur);
                } else {
                    //No more occureences of terminator
                    break;
                }
                lineCur = getLineTerminator();
            }
            return dataStr.toString();
        }
        /**
         * Read a part of BMessage including empty lines till terminator
         * @return the string till terminator, or null at end of file, or if UTF-8 is not supported
@@ -529,7 +556,12 @@ public abstract class BluetoothMapbMessage {
                }
                lineCur = getLineTerminator();
           }
           //Return string if only terminator is present.
           if ( lineCur != null && lineCur.equals(terminator)) {
               return dataStr.toString();
           } else {
               return null;
           }
        }
    };

@@ -714,7 +746,7 @@ public abstract class BluetoothMapbMessage {
            newBMsg.parseEnvelope(reader, 0);
            if ( type == TYPE.EMAIL && newBMsg instanceof BluetoothMapbMessageExtEmail) {
                ((BluetoothMapbMessageExtEmail)newBMsg)
                    .parseBodyEmail(reader.getStringTerminator("END:BBODY"));
                    .parseBodyEmail(reader.getLastStringTerminator("END:BBODY"));
            }
        } else
            throw new IllegalArgumentException("Bmessage has no BEGIN:BENV - line:" + line);
+3 −1
Original line number Diff line number Diff line
@@ -132,6 +132,8 @@ public class BluetoothMapbMessageExtEmail extends BluetoothMapbMessageMime {
                   if (beginMsg == -1) {
                       throw new IllegalArgumentException("Ill-formatted bMessage, no BEGIN:MSG");
                   }
                   //Remove a '/' in all occurrences of <CRLF>'/END:MSG' as per New Spec.
                   body = body.replaceAll("\r\n([/]*)/END\\:MSG", "\r\n$1END:MSG");
                  //Last occurence of END:MSG
                   int endMsg = body.lastIndexOf("END:MSG");
                   if (endMsg == -1) {