Skip to content

Commit

Permalink
remove ref & preref from quoted image and video
Browse files Browse the repository at this point in the history
  • Loading branch information
or-else committed Feb 19, 2023
1 parent ef873e0 commit f949564
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
6 changes: 6 additions & 0 deletions tinodesdk/src/main/java/co/tinode/tinodesdk/model/Drafty.java
Original file line number Diff line number Diff line change
Expand Up @@ -1529,6 +1529,12 @@ public Drafty replyContent(int length, int maxAttachments) {
node.text = new StringBuilder(" ");
node.tp = null;
node.children = null;
} else if (node.isStyle("IM") || node.isStyle("VD")) {
if (node.data != null) {
// Do not rend references to out-of-band large images.
node.data.remove("ref");
node.data.remove("preref");
}
}
return node;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ public void testReply() {
};
assertEquals("Reply 4 has failed", expected, actual);

// ------- Reply 5 (inline image)
// ------- Reply 5 (inline image with in-band bits only)
src = new Drafty(" ");
src.fmt = new Drafty.Style[]{
new Drafty.Style(0, 1, 0),
Expand All @@ -540,6 +540,35 @@ public void testReply() {
.putData("mime", "image/jpeg"),
};
assertEquals("Reply 5 has failed", expected, actual);

// ------- Reply 6 (inline image with in-band preview and out of band reference)
src = new Drafty(" ");
src.fmt = new Drafty.Style[]{
new Drafty.Style(0, 1, 0),
};
src.ent = new Drafty.Entity[]{
new Drafty.Entity("IM")
.putData("height", 213)
.putData("width", 638)
.putData("name", "roses.jpg")
.putData("val", "<3992, 123456789012345678901234567890123456789012345678901234567890 bytes: ...>")
.putData("ref", "/v0/file/s/77A4SDFXfzY.jpe")
.putData("mime", "image/jpeg"),
};
actual = src.replyContent(25, 3);
expected = new Drafty(" ");
expected.fmt = new Drafty.Style[]{
new Drafty.Style(0, 1, 0),
};
expected.ent = new Drafty.Entity[]{
new Drafty.Entity("IM")
.putData("height", 213)
.putData("width", 638)
.putData("name", "roses.jpg")
.putData("val", "<3992, 123456789012345678901234567890123456789012345678901234567890 bytes: ...>")
.putData("mime", "image/jpeg"),
};
assertEquals("Reply 6 has failed", expected, actual);
}

@Test
Expand Down

0 comments on commit f949564

Please sign in to comment.