diff --git a/css/base.css b/css/base.css
index 0d7050cd..01a79c7e 100644
--- a/css/base.css
+++ b/css/base.css
@@ -1718,7 +1718,6 @@ ul.tabbar li.active > a:after {
}
/* Colored uploader progress bar of variable length */
.uploader > div > span {
- position: absolute;
display: inline-block;
height: 0.3rem;
background-color: #1e88e5;
diff --git a/index.html b/index.html
index 0dbac096..bdf8797d 100644
--- a/index.html
+++ b/index.html
@@ -216,9 +216,12 @@
}
// Ensure the image is not too large
var quality = 0.78;
- while (mime == "image/jpeg" && imageBits.length * 0.75 > MAX_INBAND_ATTACHMENT_SIZE && quality > 0.15) {
- imageBits = canvas.toDataURL(mime, quality);
- quality *= 0.84;
+ if (mime == "image/jpeg") {
+ // Reduce size of the jpeg by reducing image quality
+ while (imageBits.length * 0.75 > MAX_INBAND_ATTACHMENT_SIZE && quality > 0.45) {
+ imageBits = canvas.toDataURL(mime, quality);
+ quality *= 0.84;
+ }
}
if (imageBits.length * 0.75 > MAX_INBAND_ATTACHMENT_SIZE) {
onError("The image size " + bytesToHumanSize(imageBits.length * 0.75) +
@@ -3256,6 +3259,21 @@
Message.Attachment = React.createClass({
render: function() {
+ var url = this.props.downloadUrl;
+ // Detect if the download URL is relative or absolute.
+ // Don't send credentials if the URL is absolute: we don't want to send secret
+ // keys to a third-party server.
+ if (!(/^(?:(?:[a-z]+:)?\/\/)/i.test(url))) {
+ // Relative URL. Convert to absolute and add authentication credentials as parameters.
+ var tmp = new URL(url, window.location);
+ var token = Tinode.getAuthToken();
+ if (token) {
+ tmp.searchParams.append("auth", "token");
+ tmp.searchParams.append("secret", token.token);
+ }
+ tmp.searchParams.append("apikey", API_KEY);
+ url = tmp.toString();
+ }
var filename = this.props.filename || "file_attachment";
if (filename.length > 36) {
filename = filename.substr(0, 16) + "..." + filename.substr(-16);
@@ -3271,7 +3289,7 @@
{this.props.uploader ?