[FIX] website_mail: mass mailing with fontawesome on GMail

- GMail caches the images contained in emails
 - It seems to take the opportunity to replace `%20` by `+` in the images URLs
 - Werkzeug doesn't seem to handle '+' in URL as spaces (at least not as a %20)
   (See https://github.com/mitsuhiko/werkzeug/pull/756)

When inserting a fontawesome character/image,
there are spaces in the CSS color,
e.g. `rgb(255, 255, 255)`.
And window.encodeURI, doing its job, encode this as
`rgb(255,%20255,%20255)`
This, in the URL, is supported by Werkzeug.
However, Google changes this to
`rgb(255,+255,+255)`
which is not supported by Werkzeug.

The fontawesome images were therefore not available in
mass mailing sent to GMail addresses.

This revision removes the spaces from the CSS color.
This is not the best fix, but
 - We cannot really ask Google to not change %20 by +
 - We cannot afford to wait the support of the '+' as spaces in Werkzeug

opw-648456
This commit is contained in:
Denis Ledoux
2015-09-02 16:16:32 +02:00
parent df3e7fedcf
commit c3ee6e6c1d
@@ -333,7 +333,7 @@
});
if (content) {
var size = parseInt(parseFloat($font.css("font-size"))/parseFloat($font.parent().css("font-size")),10);
var src = _.str.sprintf('/website_mail/font_to_img/%s/%s/'+$font.width(), window.encodeURI(content), window.encodeURI($font.css("color")));
var src = _.str.sprintf('/website_mail/font_to_img/%s/%s/'+$font.width(), window.encodeURI(content), window.encodeURI($font.css("color").replace(/\s/g, '')));
var $img = $("<img/>").attr("src", src)
.attr("data-class", $font.attr("class"))
.attr("style", $font.attr("style"))