1. 09 Mar, 2019 2 commits
    • Michael Gratton's avatar
      Attempt to de-mangle From names from Mailman, GitLab, etc · 6c8f1921
      Michael Gratton authored
      Some software like the above will mangle From mailbox names by appending
      "via Some Service" to the From mailbox name. This messes up generating
      default avatars for the actual people sending these messages, so
      attempt to de-mangle the names.
      
      This involves moving primary originator determination from the engine
      to the client, since it's now a policy thing. Add unit tests.
      6c8f1921
    • Michael Gratton's avatar
      Add a common interface for accessing headers from email classes. · 133167df
      Michael Gratton authored
      This allows either type to be used interchangably as a source of
      header data. Add documentation comments for the headers, add missing
      message_id property to RFC822.Message.
      133167df
  2. 02 Mar, 2019 1 commit
  3. 28 Feb, 2019 1 commit
    • Kristian Klausen's avatar
      Remove trailing whitespace · 48c93655
      Kristian Klausen authored
      find . -name '*.vala' -type f -exec sed -i 's/ *$//g' {} +
      The following files was ignored:
      test/client/composer/composer-web-view-test.vala
      test/engine/util-html-test.vala
      
      Fix #271
      48c93655
  4. 21 Feb, 2019 1 commit
  5. 12 Feb, 2019 1 commit
  6. 02 Dec, 2018 1 commit
  7. 04 Aug, 2018 2 commits
  8. 29 Jul, 2018 1 commit
  9. 28 Jul, 2018 2 commits
    • Michael Gratton's avatar
      Don't quote an RFC 822 mailbox local part if it has a '.' in the middle. · 183a9f3e
      Michael Gratton authored
      This breaks sending mail via Yahoo since it doesn't like it if the SMTP
      return path local part is quoted.
      
      We can't use GMime.utils_quote_string since it's currently broken, so
      implement our own quoter.
      183a9f3e
    • Michael Gratton's avatar
      Fix MS mailers munging plain-text signatures in HTML body parts. · f3e8b262
      Michael Gratton authored
      Geary previously wrapped plain text sigs (i.e. those that did not contain
      any HTML elements) in a DIV styled to preserve whitespace. This is all
      perfectly fine, except that certain Microsoft products munged the email
      for presentation and destroy the whitespace present in the message body,
      causing the sig to be mis-rendered.
      
      This works around their shitty software by using BRs instead of the DIV,
      also escapes other control chars and sequential whitespace as well when
      using a plain text sig. It also stops trying to smart-escape quoted reply
      text, since we know it's going to be HTML from the conversation viewer,
      meaning smart escaping only needs to be used for sigs.
      
      See issue #29
      f3e8b262
  10. 02 Jul, 2018 2 commits
  11. 21 May, 2018 1 commit
  12. 20 May, 2018 1 commit
  13. 17 May, 2018 1 commit
    • Michael Gratton's avatar
      Fix failing RFC822.Mailbox test. · ba861b8e
      Michael Gratton authored
      Reverting commit 1d8c4aea broke the mailbox class a bit. This fixes the
      issue, introduces Ascii.last_index_of which is needed by Mailbox anyway,
      and adds some test for it. Also 'optimises' Ascii.index_of bit as well.
      ba861b8e
  14. 10 May, 2018 3 commits
    • Michael Gratton's avatar
      Revert "Remove a number of redundant fns in Engine.Util.Ascii." · 40d9b779
      Michael Gratton authored
      This reverts commit 1d8c4aea.
      
      Fixes Bug 795906.
      40d9b779
    • Michael Gratton's avatar
      Ensure we always use the one, same codepath when decoding text content. · f1c79765
      Michael Gratton authored
      This introduces the Geary.RFC822.Part class, which provides a place to
      MIME entity body decoding code so it can be reused when needed. It also
      provides a place to put common GMime to Geary object conversion, and
      apply some common policy decisions, such as what is the default content
      type if none is specified.
      
      * src/engine/rfc822/rfc822-part.vala: New Part class that represents a
        MIME entity. Move code for both decoding entity body from
        RFC822.Message and code for cleaning content filename from RFC822.Util
        to here. Convert GMime entity header objects into their Geary
        equivalents and make available as properties. Provide a common means of
        determining the content type of the part if not explicitly set.
      
      * src/engine/rfc822/rfc822-message-data.vala (PreviewText.with_header):
        Construct a RFC822.Part and use that for decoding preview text. Swap
        args to make some more sense and update call sites.
      
      * src/engine/rfc822/rfc822-message.vala (InlinePartReplacer): Simply pass
        through an instance of a RFC822.Part rather than the multi-arg list,
        since that has all the data needed by replacers.
      
      * src/engine/imap-db/imap-db-attachment.vala (Attachment): Require and
        use RFC822.Part instances for obtaining attachment bodies rather than
        GMime.Part instances. Update call sites.
      f1c79765
    • Michael Gratton's avatar
      Add unit tests for Geary.RFC822.Message body content, fix a few issues. · bfe665d1
      Michael Gratton authored
      * src/engine/rfc822/rfc822-message.vala (Message): Fix has_plain_body(),
        handle the case where displayed MIME entities (as opposed to attached
        ones) with no Content-Type default to US-ASCII, per the RFC.
      
      * test/engine/rfc822-message-test.vala (MessageTest): Add tests for
        testing and accessing body content as both plain text and HTML. Use
        GResources for accessing test message bodies rather than extremely long
        const strings.
      bfe665d1
  15. 03 Mar, 2018 1 commit
  16. 07 Feb, 2018 1 commit
  17. 01 Feb, 2018 2 commits
    • Michael Gratton's avatar
      Don't flag a mailbox address without a distinct name as spoofed. · f8ef491c
      Michael Gratton authored
      This fixes annoying, albeit legit addresses like "mike@vee.net
      <mike@vee.net>" from being flagged.
      
      Followup to commit b7eea857.
      
      * src/engine/rfc822/rfc822-mailbox-address.vala (MailboxAddress): Don't
        test name for spoofyness if it's not distinct. Add unit test.
      f8ef491c
    • Michael Gratton's avatar
      Fix client use of MailboxAddress(es).to_rfc822_string(). · 7073206c
      Michael Gratton authored
      Turns out the client was in inexplicably using
      MailboxAddresses.to_rfc822_string() in a bunch of places to display
      emails to users, mostly in the composer. This fixes that.
      
      Followup to b7eea857.
      
      * src/engine/rfc822/rfc822-mailbox-addresses.vala (MailboxAddresses):
        Make list param for default ctor nullable for your testing convenience,
        add a test. Add to_full_display() method that the client should nearly
        always be using to display a list to users, use that in all the places.
        Remove empty param for list_to_string since all but one callers just
        pass in the empty string, which also fixes some stupid regressions
        introduced in commit 178ce351 that causes it actually break
        to_rfc822_string, rather than fix it as claimed, update call sites.
      7073206c
  18. 31 Jan, 2018 5 commits
    • Michael Gratton's avatar
      40b460dc
    • Michael Gratton's avatar
    • Michael Gratton's avatar
      Ensure encoded mailbox addresses are decoded correctly. · 8a1906fa
      Michael Gratton authored
      Both RFC mailbox address names and mailboxes/local-names may by RFC 2047
      be Quoted-Printable or Base64 encoded. This patch ensures these parts are
      correctly decoded when parsing a RFC 822 message, so that they are
      displayed to the user in human-readable form.
      
      Part 2 of Mailsploit mitigation.
      
      * src/engine/rfc822/rfc822-message.vala (Message): Since GMime.Message's
        convenience properties for accessing header values such as senders,
        recipients, etc. in string form are presented as human-readable, not
        RFC822 compliant strings, we can't re-parse them for use by this class
        when it is being constructed from a GMime-based source. Instead,
        iterate over all headers to get the raw values and parse those we are
        interested in instead. Add unit tests.
      
      * src/engine/rfc822/rfc822-mailbox-address.vala (BaseObject): Add gmime
        constructor so we can handle construction and decoding from a GMime
        InternetAddressMailbox object in a consistent way. Ensure both names
        are decoded correctly, and mailboxes are decoded at all, from both
        GMime and IMAP sources. If a GMime source's address has no @-symbol,
        try to decode the whole thing first it in case the whole address is
        encoded. Add unit tests.
      
      * src/engine/rfc822/rfc822-mailbox-addresses.vala (MailboxAddresses):
        Add append method and handle group addresses here instead of in Message
        to simplify updated Message implementation.
      
      * src/engine/rfc822/rfc822-message-data.vala (MessageData): Add append
        method to simplify updated Message implementation.
      8a1906fa
    • Michael Gratton's avatar
      Ensure mailbox addresses escaped correctly when formatted as RFC 822. · 8810e957
      Michael Gratton authored
      * src/engine/rfc822/rfc822-mailbox-address.vala (MailboxAddress): Escape
        and encode name and mailbox (local-part) when serialising as a RFC 822
        string. Provide a means to get a RFC 822 version of the address only
        for SMTP. Add unit tests.
      
      * src/engine/smtp/smtp-request.vala (MailRequest): Use proper RFC 822
        formatted version of mailbox addresses.
      8810e957
    • Michael Gratton's avatar
      Check for spoofed sender addresses, only display the address if so. · 71e0e683
      Michael Gratton authored
      This adds a check for malware spoofing of RFC 822 mailbox addresses such
      as those found in Mailsploit, and if found only displays the email
      address part and not the mailbox name part.
      
      Part 1 of Mailsploit mitigation.
      
      * src/engine/rfc822/rfc822-mailbox-address.vala (MailboxAddress): Add new
        is_spoofed method to check if the mailbox address looks like it has
        been spoofed. Add is_distinct method to determine if the name and the
        label is the same. Do whitespace and non-printing character stripping
        when generating display versions of the mailbox address, rename methods
        to make it more obvious what they do and update call sites. Add unit
        tests to cover all this.
      
      * src/client/conversation-viewer/conversation-message.vala
        (ConversationMessage): Check name is distinct and is not valid before
        displaying it. Use new MailboxAddress methods for getting display
        versions of the address, to ensure we get the stripped versions of the
        addresses.
      
      * src/client/conversation-list/formatted-conversation-data.vala
        (ParticipantDisplay): Ensure full addresses are always HTML-markup
        escaped before displaying them as markup, to avoid dropping "<address>"
        values as invalid HTML. Always show the full address if an address is
        invalid.
      
      * src/engine/util/util-string.vala (reduce_whitespace): Strip not only
        whitespace but also non-printing characters. Add unit tests.
      71e0e683
  19. 09 Jan, 2018 1 commit
  20. 18 Dec, 2017 2 commits
  21. 04 Dec, 2017 1 commit
  22. 01 Dec, 2017 1 commit
    • Michael Gratton's avatar
      Fix some engine build warnings. · d66e4526
      Michael Gratton authored
      * src/engine/imap/command/imap-create-command.vala: Enums can't be null?
      
      * src/engine/rfc822/rfc822-message.vala: Gee.Map has deprecated contains?!
      d66e4526
  23. 16 Nov, 2017 1 commit
  24. 14 Sep, 2017 1 commit
  25. 04 Mar, 2017 1 commit
  26. 15 Feb, 2017 1 commit
    • Michael Gratton's avatar
      Clean up DB handling of attachments without specified file names. · 99252886
      Michael Gratton authored
      This could probably use a DB migration to set all attachments will "none"
      as their filename to NULL, but that's a lot of trouble for little gain.
      
      * src/client/conversation-viewer/conversation-email.vala (if): Remove
        workaround for "none" attachment file names.
      
      * src/client/conversation-viewer/conversation-message.vala
        (ConversationMessage::inline_image_replacer): Handle translation for
        null attachment file names here, rather than in the engine.
      
      * src/engine/api/geary-email.vala
        (Email::get_searchable_attachment_list): Don't bother appending file
        names for attachments when they are null.
      
      * src/engine/imap-db/imap-db-attachment.vala (Attachment): Use a const
        for null file name replacement string so it can be used elsewhere.
      
      * src/engine/imap-db/imap-db-folder.vala (Folder::do_list_attachments):
        Clean up old "none" file names when loading from DB.
        (Folder::do_save_attachments_db): Allow for file name being null.
      
      * src/engine/rfc822/rfc822-message.vala (Message::InlinePartReplacer):
        Allow file name to be null, update call sites.
      
      * src/engine/rfc822/rfc822-utils.vala (get_clean_attachment_filename):
        Don't attempt to translate null filenames, just return it null. Update
        call sites.
      99252886
  27. 31 Jan, 2017 2 commits
    • Michael Gratton's avatar
      Split composer web view up into multiple parts. · 96ffcdb6
      Michael Gratton authored
      This lets us implement changing signatures and deleting bottom-quoted
      messages without having to reload the whole view, and makes it possible
      to target only the user's content when modifying for send, etc.
      
      * src/client/composer/composer-web-view.vala (ComposerWebView): Move
        composer CSS into composer-web-view.css resource file, load it when
        loading JS resource and add it to the view's user content manager.
        (ComposerWebView::load_html): Split up body, signature and quote into a
        DIV container for each.
        (ComposerWebView::linkify_content): Replaced with ::clean_content,
        which will also tidy up internal markup before sending. Update call
        site and unit test.
      
      * src/engine/rfc822/rfc822-utils.vala (Geary.RFC822.Utils): Remove some
        more obtrusive white space when sending replies/forwards.
      
      * test/client/composer/composer-web-view-test.vala,
        test/js/composer-page-state-test.vala: Update tests to expect new HTML
        and text output from ComposerWebView and use of individual parts for
        composer markup.
      
      * ui/composer-web-view.js (ComposerPageState): Replace messageBody
        property and uses with bodyPart, signaturePart and quotePart. Set these
        content-editable on load. Move listeners from messageBody back to the
        document.body so they also listen for events on the additional
        parts. Keep track of text cursor location within the parts and set a
        class if so, to work around the lack of :focus-inside support.
        (ComposerPageState::updateSignature): Implement by updating the inner
        content of the signature part.
        (ComposerPageState::deleteQuotedMessage): Implement by removing the
        quote part from the DOM tree.
        (ComposerPageState::containsAttachmentKeyword): Consider only the
        bodyPart when scanning for attachments, remove hacks for ignoring the
        signature any any quoted message.
        (ComposerPageState::linkifyContent): Mirror ClientWebView change and
        replace with ::cleanContent. Ensure existing parts have contenteditable
        and focus class removed, remove signature and quote parts if empty.
        (ComposerPageState::getHtml): Generate HTML using clones of the three
        parts, so we can rmeove contenteditable and focus classes without
        modifying the actual DOM.
        (ComposerPageState::selectionChanged): Update focus class on parts as
        needed.
      96ffcdb6
    • Michael Gratton's avatar
      Clean up how composer loads content into its web view. · dec06d93
      Michael Gratton authored
      The main gist of this is to ensure that the composer's widgets are
      constructed seperately to loading its content, and that we only ever call
      ComposerWebView::load_html precisely once per composer instance.
      
      * src/client/composer/composer-widget.vala: Remove referred message,
        quote text and draft flag param from constructor signature, move any
        calls that loaded data from them to new load method. Don't load
        anything into the editor here. Make loading the signature file async,
        and call new ComposerWebView::updateSignature method on the editor to
        update it.
        (ComposerWidget::load): New async message for loading content into the
        composer. Move related code from the constructor and GearyController
        here, make methods that were previously public for that private
        again. Tidy up calls a bit now that we have a single place from which
        to do it all, and can understand the process a bit better.
        (ComposerWidget::on_editor_key_press_event): Don't reload the editor to
        remove the quoted text, call new ComposerWebView::delete_quoted_message
        method on it instead.
      
      * src/client/composer/composer-web-view.vala
        (ComposerWebView): Add ::delete_quoted_message ::update_signature
        methods, thunk to JS.
        (ComposerWebView::load_html): Add quote and is_draft parameters,
        construct HTML for the composer using apporporate spacing here, instead
        of relying on all the disparate parts from doing the right thing.
      
      * src/client/application/geary-controller.vala
        (GearyController::create_compose_widget_async): Load composer content
        after adding it to the widget hierarchy, set focus only after
        everything is set up.
      
      * src/engine/rfc822/rfc822-utils.vala (quote_email_for_reply,
        quote_email_for_forward): Don't add extra padding around quoted parts -
        let callers manage their own whitespace.
      
      * test/client/components/client-web-view-test-case.vala
        (TestCase:load_body_fixture): Make HTML param non-nullable, update
        subclasses.
      
      * ui/composer-web-view.js (ComposerPageState): Add ::updateSignature and
        ::deleteQuotedMessage method stubs.
      dec06d93