msgraph-sdk-go icon indicating copy to clipboard operation
msgraph-sdk-go copied to clipboard

Panic while parsing weird email address

Open drummonds opened this issue 1 year ago • 2 comments

I have received some I think mailicious email but the from field (from Outlook message details was:

From: =?UTF-8?B?=RHJ1bW1vbmRzIEhSIC0gU2hhcmVkIHZpYSBPbmxpbmVEb2Nz?= ,------_------[email protected]

This caused the address to panic.

this_message := message.GetFrom()
this_email := this_message.GetEmailAddress()
address := *this_email.GetAddress()

In the mean time will just recover and then process appropriately

drummonds avatar Mar 08 '24 10:03 drummonds

@drummonds from the given snippet it looks like address field might be a nil value. To be certain however please share the json value from the server. I'd like to be sure that this is not a serialization issue.

In the meantime, if the address field is a nil value you might want to check it instead of catching the panic i.e

address  := this_email.GetAddress()
if address  != nil {
    // process address  
}

rkodev avatar Apr 25 '24 13:04 rkodev

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.