在电子邮件主题动画图标 [英] Animated icon in email subject

查看:250
本文介绍了在电子邮件主题动画图标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道数据URI S IN其中 的base64 烯codeD数据可以使用内联,如图像。今天,我收到一封电子邮件,实际上是一个垃圾邮件在其中有在其主题动画(GIF)图标:

I know about Data URIs in which base64 encoded data can be used inline such as images. Today I received an email actually an spam one in which there was an animated (gif) icon in its subject:

下面是单独的图标:

所以,唯一的事情没过我的脑海都是关于数据的URI,如果Gmail允许受插入某种表情。我看到邮件的完整详细的版本,并指出主题在下面的图片:

So the only thing did cross my mind was all about Data URIs and if Gmail allows some sort of emoticons to be inserted in subject. I saw the full detailed version of email and pointed to subject line at the below picture:

所以,GIF来自 =?UTF-8?B'876Urg ==?= 连接codeD字符串,它类似于数据URI方案但我找不到得到的,图标出来。这里是元素的HTML源代码:

So GIF comes from =?UTF-8?B?876Urg==?= encoded string which is similar to Data URI scheme however I couldn't get the icon out of it. Here is element HTML source:

长话短说,有很多表情从 https://mail.google.com/mail/e/XXX ,其中 XXX 是十六进制数字。他们无处证件或我找不到它。如果这是有关数据URI,所以怎么可能将它们包含在Gmail的电子邮件的主题? (我转发该电子邮件到雅虎电子邮件帐户,看到 [?] 而不是图标),如果不是,那怎么说EN codeD字符串进行分析?

Long story short, there are lots of emoticons from https://mail.google.com/mail/e/XXX where XXX are hexadecimal numbers. They are documented nowhere or I couldn't find it. If that's about Data URI, so how is it possible to include them in Gmail's email subject? (I forwarded that email to a yahoo email account, seeing [?] instead of icon) and if it's not, then how that encoded string is parsed?

推荐答案

他们被称为内部为 goomoji ,他们似乎是一个非标准的UTF-8扩展。当的Gmail遇到这些字符中的一个,它是由对应的图标替换。我没能找到他们的任何文件,但我可以反向工程的格式。

Short description:

They are referred to internally as goomoji, and they appear to be a non-standard UTF-8 extension. When Gmail encounters one of these characters, it is replaced by the corresponding icon. I wasn't able to find any documentation on them, but I was able to reverse engineer the format.


这些图标实际上,根据插入表情符号面板显示的图标。

Those icons are actually the icons that appear under the "Insert emoticons" panel.

虽然我没有看到 52E 列表中的图标,有几个人遵循相同的约定。

While I don't see the 52E icon in the list, there are several others that follow the same convention.

请注意,也有一些图标,其名称是prefixed,如 gtalk.03C 。我无法确定是否或如何将这些图标可以以这种方式使用。

Note that there are also some icons whose names are prefixed, such as gtalk.03C . I was not able to determine if or how these icons can be used in this manner.


这实际上不是一个数据URI ,尽管它有一些相似之处。它实际上是对编码电子邮件科目非ASCII字符,在 RFC 2047定义一个特殊的语法。基本上,它的工作原理是这样的。

It's not actually a Data URI, though it does share some similarities. It's actually a special syntax for encoding non-ASCII characters in email subjects, defined in RFC 2047. Basically, it works like this.

=?charset?encoding?data?=

所以,在我们的例子字符串,我们有以下的数据。

So, in our example string, we have the following data.

=?UTF-8?B?876Urg==?=


  • 字符集 = UTF-8

  • 编码 = B (指的base64)

  • 数据 = 876Urg ==

    • charset = UTF-8
    • encoding = B (means base64)
    • data = 876Urg==

    • 我们知道,不知何故, 876Urg == 表示图标 52E ,但如何?

      We know that somehow, 876Urg== means the icon 52E, but how?

      如果我们采用base64德code 876Urg == ,我们得到 0xf3be94ae 。这看起来像在二元以下内容:

      If we base64 decode 876Urg==, we get 0xf3be94ae. This looks like the following in binary:

      11110011 10111110 10010100 10101110
      

      这些位是4个字节的UTF-8 EN codeD的性格是一致的。

      These bits are consistent with a 4-byte UTF-8 encoded character.

      11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
      

      因此​​,相关的位如下:

      So the relevant bits are the following.:

           011   111110   010100   101110
      

      或者当对齐:

      00001111 11100101 00101110
      

      在十六进制,这些字节如下:

      In hexadecimal, these bytes are the following:

      FE52E
      

      正如你所看到的,除了 FE preFIX这是presumably来区分 goomoji 其他UTF-8字符的图标,它匹配 52E 的图标的网址。一些测试证明,这适用于其它图标如此。

      As you can see, except for the FE prefix which is presumably to distinguished the goomoji icons from other UTF-8 characters, it matches the 52E in the icon URL. Some testing proves that this holds true for other icons.


      当然,这可以编写脚本。我创建了下面的Python code代表我的测试。这些功能可以为Base64 EN codeD字符串转换为并从URL中找到短期十六进制字符串。请注意,这code是Python 3里写的,是不是Python的2兼容。

      This can of course be scripted. I created the following Python code for my testing. These functions can convert the base64 encoded string to and from the short hex string found in the URL. Note, this code is written for Python 3, and is not Python 2 compatible.

      import base64
      
      def goomoji_decode(code):
          #Base64 decode.
          binary = base64.b64decode(code)
          #UTF-8 decode.
          decoded = binary.decode('utf8')
          #Get the UTF-8 value.
          value = ord(decoded)
          #Hex encode, trim the 'FE' prefix, and uppercase.
          return format(value, 'x')[2:].upper()
      
      def goomoji_encode(code):
          #Add the 'FE' prefix and decode.
          value = int('FE' + code, 16)
          #Convert to UTF-8 character.
          encoded = chr(value)
          #Encode UTF-8 to binary.
          binary = bytearray(encoded, 'utf8')
          #Base64 encode return end return a UTF-8 string. 
          return base64.b64encode(binary).decode('utf-8')
      

      的例子:

      print(goomoji_decode('876Urg=='))
      print(goomoji_encode('52E'))
      

      输出:

      52E
      876Urg==
      

      和,当然,只要寻找一个图标的网址需要创建Gmail中的新草案,插入你想要的图标,并使用浏览器的DOM检查。

      And, of course, finding an icon's URL simply requires creating a new draft in Gmail, inserting the icon you want, and using your browser's DOM inspector.

      这篇关于在电子邮件主题动画图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆