Gmail automatically urlencodes links in mail - angularjs

I'm trying to send an email to a gmail account containing a link which looks like this:
http://www.example.com/#/something#param=1
This is a link to an AngularJS application which needs the second '#' as a separator.
The problem is that gmail changes the seconds '#' to '%23' and this causes the application not to recognize the char as a separator.
Is there anything I can do with this?
Thanks.

I did a quick test using gmail to try to figure out what happens.
Here is the raw message
MIME-Version: 1.0
Received: by 10.96.50.232 with HTTP; Mon, 19 Jan 2015 05:44:30 -0800 (PST)
Date: Mon, 19 Jan 2015 14:44:30 +0100
Delivered-To: *******#gmail.com
Message-ID: <CPZt8dX3Q17wXmU7UT2iXp7q4tSn1UsDmyiUbXFVK7xE2Q0C10A#mail.gmail.com>
Subject: test
From: <name> <*******#gmail.com>
To: <name> <*******#gmail.com>
Content-Type: multipart/alternative; boundary=20cf303b41179134a6050d0185f4
--20cf303b41179134a6050d0185f4
Content-Type: text/plain; charset=UTF-8
http://www.example.com/#/something#param=1
--20cf303b41179134a6050d0185f4
Content-Type: text/html; charset=UTF-8
<div dir="ltr">http://www.example.com/#/something#param=1<br></div>
--20cf303b41179134a6050d0185f4--
The original message is showing the correct values, but I also noticed how my actual gmail client shows the second # as the html encoded %23.
Surprisingly enough, in contrast to what I suggested in my comment, using plain-text will actually give the desired result.
MIME-Version: 1.0
Received: by 10.96.50.232 with HTTP; Mon, 19 Jan 2015 06:06:39 -0800 (PST)
Date: Mon, 19 Jan 2015 15:06:39 +0100
Delivered-To: *****#gmail.com
Message-ID: <KMBt8bX2CrmEL66iRFAJ+_s_1W2eodD=9X=bMdsBK_13qzh6DaA#mail.gmail.com>
Subject: test4
From: <name> <*****#gmail.com>
To: <name> <*****#gmail.com>
Content-Type: text/plain; charset=UTF-8
http://www.example.com/#/something#param=1
I don't know how your AngularJS application reads the link from the email, so plain-text may not be an option, but the link in the above email is mapped to http://www.example.com/#/something#param=1 in my gmail client.

Related

Gatling - extract token from response headers

I'm a newer in Gatling and I created a POST login request which returns the following response headers:
HTTP/1.1 302
Set-Cookie: JSESSIONID=ECA5F6FEA172B13BF5D445399C9C0962; Path=/; HttpOnly
Location: http://localhost:20001/index;jsessionid=ECA5F6FEA172B13BF5D445399C9C0962
Content-Language: en-US
Content-Length: 0
Date: Thu, 06 May 2021 16:01:20 GMT
I need to extract JSESSIONID value and use it in other requests.
I tried:
.check(regex("JSESSIONID=(.*?);").find.saveAs("token")))
however got an error
> regex(JSESSIONID=(.*?);).findAll.exists, found nothing 1 (100.0%)
Any help would be greatly appreciated!
You need use headerRegex
.check(headerRegex("Set-Cookie", """JSESSIONID=(.*?);"""").saveAs("token"))

How can I tell that the content of this URL is gzip-encoded?

I am downloading a Helm chart from https://kubernetes-charts.storage.googleapis.com/redis-0.5.1.tgz. (The fact that it is Redis or related to Helm or anything in particular is irrelevant to this question, which is just about things like Content-Encoding and so on.)
When I check its headers like this:
$ curl -H "Accept-Encoding: gzip" -I https://kubernetes-charts.storage.googleapis.com/redis-0.5.1.tgz
…I do not see a Content-Encoding header in the output, and the Content-Type is listed as being application/x-tar:
HTTP/1.1 200 OK
X-GUploader-UploadID: AEnB2UqBzSXfTToMAdMARXSjJeN0on3jaNY3u74eXcWfvqsOwRpi38Xc6T0XrrmY4otPeySaYRwXyHccHYtChoPAgFQwYZhQMhcpZRWtZURRANGdfRJoupI
Expires: Tue, 27 Jun 2017 00:21:59 GMT
Date: Mon, 26 Jun 2017 23:21:59 GMT
Cache-Control: public, max-age=3600
Last-Modified: Fri, 05 May 2017 03:03:41 GMT
ETag: "e4184c81a58fb731283847222a1f4005"
x-goog-generation: 1493953421241613
x-goog-metageneration: 1
x-goog-stored-content-encoding: identity
x-goog-stored-content-length: 3550
x-goog-meta-goog-reserved-file-mtime: 1493953414
Content-Type: application/x-tar
x-goog-hash: crc32c=bQHveg==
x-goog-hash: md5=5BhMgaWPtzEoOEciKh9ABQ==
x-goog-storage-class: STANDARD
Accept-Ranges: bytes
Content-Length: 3550
Server: UploadServer
Alt-Svc: quic=":443"; ma=2592000; v="39,38,37,36,35"
The resulting file, when downloaded, is a gzipped tar archive.
What is the proper way of programmatically detecting that the payload is in fact gzipped? Or is this a problem with the web server in question?
I think the server is misconfigured. Since .tgz is just abbreviation for .tar.gz it should get the content type application/gzip-
Content-Type: application/x-tar
this header tells you the type, but i'm not sure that's gzip
https://superuser.com/questions/901962/what-is-the-correct-mime-type-for-a-tar-gz-file
see accepted answer at
How to check if a file is gzip compressed? . for way to identify programmatically

Icalendar .ics not showing issue after adding html content

I got this issue with icalendar, it doesn't show the attachment and the confirmation button when sent to gmail,yahoo, aoutlook.com.
it was working before without html message and multipart/mixed header.
now when i recieve the email it only show me the the text of the calendar, it doesn't recognize it.
Content-type: multipart/mixed; boundary="982f8d486c3cbed0e28b314e7a433c3d"
--982f8d486c3cbed0e28b314e7a433c3d
Content-Type: multipart/alternative; boundary="19f4b0e33c6f735ae6f858b1df7b72f2"
--19f4b0e33c6f735ae6f858b1df7b72f2
Content-Type: text/calendar; method=REQUEST; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//Testa//Tes//EN
METHOD:REQUEST
BEGIN:VEVENT
UID:20150914T205515-998107994-domain.com
DTSTAMP:20150914T205515
DTSTART:20150915T195500Z
DTEND:20150915T195500Z
ORGANIZER;CN=soy:MAILTO:admin#adminm.org
ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=xxx.yyy#gmail.com:MAILTO:xxx.yyy#gmail.com
LOCATION:hj
SUMMARY:Rendez-vous
BEGIN:VALARM
TRIGGER:-PT15M
ACTION:DISPLAY
DESCRIPTION:Reminder
END:VALARM
END:VEVENT
END:VCALENDAR
--19f4b0e33c6f735ae6f858b1df7b72f2--
--982f8d486c3cbed0e28b314e7a433c3d
Content-Type: application/ics; name="Rv-invite.ics"
Content-Disposition: attachment; filename="Rv-invite.ics"
Content-Transfer-Encoding: base64
X-Mailer: Microsoft Office Outlook 12.0
X-Mailer: CakePHP Email
Date: Mon, 14 Sep 2015 20:55:16 +0200
Message-ID: <55f71814db484f8fa8923d8664ca69fc#localhost>
Subject: Rendez-vous
MIME-Version: 1.0
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 8bit
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
<title>Emails/html</title>
</head>
<body>
<p>Dear,</p>
<p>Mr xxx sent an appointment</p>
</body>
</html>
thanks in advance.
Well your second body part has 2 content-type headers:
Content-Type: application/ics; name="Rv-invite.ics"
Content-Disposition: attachment; filename="Rv-invite.ics"
Content-Transfer-Encoding: base64
and
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 8bit
It looks like some of the headers also belong to the top level and not in the body part:
X-Mailer: Microsoft Office Outlook 12.0
X-Mailer: CakePHP Email
Date: Mon, 14 Sep 2015 20:55:16 +0200
Message-ID: <55f71814db484f8fa8923d8664ca69fc#localhost>
Subject: Rendez-vous
MIME-Version: 1.0
See also this post about the correct MIME structure to use in general: Multipart email with text and calendar: Outlook doesn't recognize ics

Emails sent via GMail API are empty

I have been switching from Google App Engine MailServier to the GMail API recently and I'm running into a strange issue:
The emails are being sent out correctly, but on the recipients end the body is empty! (Subject is still there).
I'm creating HTML emails with optional attachments and encode them using the snippet from the GMail API docs:
I'm using the snippet from the GMail API docs to encode the email:
public static Message createMessageWithEmail(MimeMessage email)
throws MessagingException, IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
email.writeTo(baos);
String encodedEmail = Base64.encodeBase64URLSafeString(baos.toByteArray());
Message message = new Message();
message.setRaw(encodedEmail);
return message;
}
When looking into my "Sent" folder in GMail, I can see the message just fine (it is an HTML email body):
Received: from 889121556365-na05chj5g3il9flll2l3otqeh7q7ja22.apps.googleusercontent.com
named unknown
by gmailapi.google.com
with HTTPREST;
Thu, 18 Jun 2015 05:29:12 -0400
From: daniel.florey#gmail.com
To: daniel.florey#floreysoft.net
Message-Id: <CAHWc4t9o6gpRs_HT0Y8E1szJtDTwfSMS7OH+jVro-LiA1kBLJw#mail.gmail.com>
Subject: Test
MIME-Version: 1.0
Content-Type: multipart/mixed;
boundary="----=_Part_1_15413936.1434619752068"
Date: Thu, 18 Jun 2015 05:29:12 -0400
------=_Part_1_15413936.1434619752068
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: base64
------=_Part_1_15413936.1434619752068
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: base64
TnVyIGVpbiBUZXN0ITxkaXY+PGJyPjwvZGl2PjxkaXY+PGZvbnQgc2l6ZT0iNiI+SGFoYWhhITwv
Zm9udD48L2Rpdj4=
------=_Part_1_15413936.1434619752068--
On the recipients end the same message is empty:
Delivered-To: daniel.florey#floreysoft.net
Received: by 10.140.94.46 with SMTP id f43csp925254qge;
Thu, 18 Jun 2015 02:29:13 -0700 (PDT)
X-Received: by 10.180.94.39 with SMTP id cz7mr61405623wib.66.1434619752847;
Thu, 18 Jun 2015 02:29:12 -0700 (PDT)
Return-Path: <daniel.florey#gmail.com>
Received: from mail-wi0-x233.google.com (mail-wi0-x233.google.com. [2a00:1450:400c:c05::233])
by mx.google.com with ESMTPS id ju2si35306720wid.33.2015.06.18.02.29.12
for <daniel.florey#floreysoft.net>
(version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
Thu, 18 Jun 2015 02:29:12 -0700 (PDT)
Received-SPF: pass (google.com: domain of daniel.florey#gmail.com designates 2a00:1450:400c:c05::233 as permitted sender) client-ip=2a00:1450:400c:c05::233;
Authentication-Results: mx.google.com;
spf=pass (google.com: domain of daniel.florey#gmail.com designates 2a00:1450:400c:c05::233 as permitted sender) smtp.mail=daniel.florey#gmail.com;
dkim=pass header.i=#gmail.com;
dmarc=pass (p=NONE dis=NONE) header.from=gmail.com
Received: by wicgi11 with SMTP id gi11so7511413wic.0
for <daniel.florey#floreysoft.net>; Thu, 18 Jun 2015 02:29:12 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20120113;
h=from:mime-version:date:message-id:subject:to:content-type;
bh=47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=;
b=aYXfdO2NjbNXjQglJuER7ul/PfgQ84kxfMtDvUr4XEYuYEEhOZzWTiBj4Aedq8xtrH
5upGVtwKjHVc0R36BcFUD0tTq5IXLXsESIMEXL0pV0KJCFnXvMRCC+rn0uUzbCVWcSp4
LG8RxP9YTWRMhWQUattO/vI43kV34EMLax+irhY+98pXkaHHrNd5+GGO2OMzdcRPOpCg
gZ9bdQeEDsSrW4YJrxdKA/hJfCh6ceZ9mDgeRPiD+tC9AibhPK1QDqM8SKzh1QRoSZtl
yPGyJWGUXYMM9o7XaCh8ZenKLvd/AdTF2oAbwyqXnycAvOZqqj03x4sA38o5c4fEjkIQ
rAxQ==
X-Received: by 10.180.72.176 with SMTP id e16mr26991312wiv.12.1434619752466;
Thu, 18 Jun 2015 02:29:12 -0700 (PDT)
Received: from 889121556365-na05chj5g3il9flll2l3otqeh7q7ja22.apps.googleusercontent.com
named unknown by gmailapi.google.com with HTTPREST; Thu, 18 Jun 2015 05:29:12 -0400
From: daniel.florey#gmail.com
MIME-Version: 1.0
Date: Thu, 18 Jun 2015 05:29:12 -0400
Message-ID: <CAHWc4t9o6gpRs_HT0Y8E1szJtDTwfSMS7OH+jVro-LiA1kBLJw#mail.gmail.com>
Subject: Test
To: daniel.florey#floreysoft.net
Content-Type: text/plain; charset=UTF-8
The content type has been switched to text/plain?!
Any ideas?

Mocking or Stubbing mtime for File::Stat

My object GETs a file over HTTP.
It does so, using the If-Modified-Since header. If the files has not been modified since the time in the header a Not Modified response will be returned and the file should not be fetched&written. Like so:
class YouTube
#...
def parse
uri = URI("http://i.ytimg.com/vi/#{#id}/0.jpg")
req = Net::HTTP::Get.new(uri.request_uri)
if File.exists? thumbname
stat = File.stat thumbname
req['If-Modified-Since'] = stat.mtime.rfc2822
end
res = Net::HTTP.start(uri.hostname, uri.port) {|http|
http.request(req)
}
File.open(thumbname, 'wb') do |f|
f.write res.body
end if res.is_a?(Net::HTTPSuccess)
end
#...
end
I want to test both cases (in both cases, a file on disk exists). To do so, I'd need to stub either something in Net::HTTP, or I need to stub the File.stat to return an mtime for which I a sure the online resource will return a new or Not-modified-since.
Should I stub (or even mock) Net::HTTP? And if so, what?
Or should I stub mtime to return a date far in the past or far in the future to enforce or suppress the Not-modified Header?
Edit: Diving deeper into the matter, I learned that the i.ytimg.com-domain does not support these headers. So i'll need to solve this by inspecing JSON from the YouTube API. However, the problem "What and how to mock when testing if-modified-since-headers" still stands.
Here is how I conclude the domain does not support this:
$curl -I --header 'If-Modified-Since: Sun, 24 Mar 2013 17:33:29 +0100' -L http://i.ytimg.com/vi/D80QdsFWdcQ/0.jpg
HTTP/1.1 200 OK
Content-Type: image/jpeg
Date: Sun, 24 Mar 2013 16:31:10 GMT
Expires: Sun, 24 Mar 2013 22:31:10 GMT
X-Content-Type-Options: nosniff
Server: sffe
Content-Length: 13343
X-XSS-Protection: 1; mode=block
Cache-Control: public, max-age=21600
Age: 822
There is no "Last-Modified" there. Illustrated with another call, to exaple.com, which does support the if-modified-since headers.
$curl -I --header 'If-Modified-Since: Sun, 24 Mar 2013 17:33:29 +0100' -L example.com
HTTP/1.0 302 Found
Location: http://www.iana.org/domains/example/
Server: BigIP
Connection: Keep-Alive
Content-Length: 0
HTTP/1.1 302 FOUND
Date: Sun, 24 Mar 2013 16:47:47 GMT
Server: Apache/2.2.3 (CentOS)
Location: http://www.iana.org/domains/example
Connection: close
Content-Type: text/html; charset=utf-8
HTTP/1.1 304 NOT MODIFIED
Date: Sun, 24 Mar 2013 16:47:47 GMT
Server: Apache/2.2.3 (CentOS)
Connection: close

Resources