getMsgTextFromStream: inserting breaklines problem

Talk about add-ons and extension development.
morat
Posts: 6403
Joined: February 3rd, 2009, 6:29 pm

Re: getMsgTextFromStream: inserting breaklines problem

Post by morat »

user2018 wrote:I would like to retrieve the body text without the headers.
morat wrote:code snippet based on the |IETstoreBody| function
Try this:

Code: Select all

  text = text.replace("$%$%$", ":");
+ for (var i = 0; i < 9; i++) text = text.replace(/^.*\r\n/, "");
  var clipboard = Components.classes["@mozilla.org/widget/clipboardhelper;1"].
    getService(Components.interfaces.nsIClipboardHelper);
user2018
Posts: 196
Joined: September 23rd, 2018, 11:07 am

Re: getMsgTextFromStream: inserting breaklines problem

Post by user2018 »

Thanks a lot!! This seems to work now. I am not sure about the intention behind the following code:

Code: Select all

    if (os.indexOf("win") > -1)
      text = strValue.replace(/(.+\r\n?)*/, "");
    else
      text = strValue.replace(/(.+\n?)*/, "");
    text = text.replace(/\r?\n+/g, "\r\n");
    text = text.replace(/^(\r\n)/g, "");
    text = text.replace(/(\r\n)$/g, "");
I have commented it, as it seems to remove empty lines within the message body, that I would like to preserve (as they were in the original message).
Post Reply