Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-18394] MobileWeb: The text format in Message Body is broken

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionNot Our Bug
Resolution Date2015-12-01T00:17:54.000+0000
Affected Version/sRelease 3.4.1, Release 3.5.0
Fix Version/sn/a
ComponentsMobileWeb
LabelsSupportTeam
ReporterMauro Parra-Miranda
AssigneeChris Barber
Created2015-01-16T19:26:45.000+0000
Updated2017-03-14T05:04:53.000+0000

Description

Problem Description

If you try to use new lines or similar to create format to a message body, the resultant text in the mail app (either gmail or mail) will be wrongly shown. Example:
var messageBody = 'I would like to share this awesome app with you: '+
                                '\n\nApple: http://google.com'+
                                '\nAndroid: http://google.com'+
                                '\n\nPlease note, the this app is intended for awesome people '+
                                'whose employer are awesome. The app '+
                                'will only work for those who are awesome.';
Will be added to the mail as shown, Ignoring the format.
I would like to share this awesome app with you: %0A%0AApple: http://google.com%0AAndroid: http://google.com%0A%0APlease note, the this app is intended for awesome people whose employer are awesome. The app will only work for those who are awesome.

Steps to reproduce

1. Create a new mobile project Classic Titanium 2. Paste this code to app.js:
var win = Ti.UI.createWindow({backgroundColor:'white'});
var label = Ti.UI.createLabel({text:"click here"});

function doClick(e) {
    var messageBody = 'I would like to share this awesome app with you: '+
                                '\n\nApple: http://google.com'+
                                '\nAndroid: http://google.com'+
                                '\n\nPlease note, the this app is intended for awesome people '+
                                'whose employer are awesome. The app '+
                                'will only work for those who are awesome.';
        var data = {
                subject : 'The most awesome App',
                recipient : '',
                messageBody : messageBody
        }
        openFeedbackDialog(data);
}

function openFeedbackDialog(emailData){
        var subject             = emailData.subject;
        var toRecipients        = [emailData.recipient];
        var ccRecipients        = [];
        var messageBody         = emailData.messageBody;

        var emailDialog = Ti.UI.createEmailDialog({
                subject : subject,
                toRecipients : toRecipients,
                ccRecipients : ccRecipients,
                messageBody : messageBody
        }).open();
};

label.addEventListener("click",doClick);

win.add(label);
win.open();
3. Deploy to mobile web, upload it to a webserver. 4. Open that page in your Android within Chrome browser. 5. Click on "Click here" 6. Will open the email dialog, with the wrong text as shown.

Extra information

It only fails if you do the mix "Mobile web + Chrome browser in Android + Mail/Gmail in Android".

Comments

  1. Chris Barber 2015-12-01

    Mobile web uses the mailto: protocol which the browser will open using the default mail client. Since the email body is put in the URL, it needs to be encoded and thus \\n becomes %0A. This is the correct behavior. The problem is Chrome for Android and/or the default Android mail client doesn't properly decode the body. Here's the Chromium bug: https://code.google.com/p/chromium/issues/detail?id=424889. As stated in the Chromium ticket, it appears to have been fixed.
  2. Lee Morris 2017-03-14

    Closing ticket as the issue is not our bug.

JSON Source