UX: strip base64 image URLs when converting HTML to markdown.

UX: strip base64 image URLs when converting HTML to markdown.

diff --git a/app/assets/javascripts/discourse/lib/to-markdown.js b/app/assets/javascripts/discourse/lib/to-markdown.js
index 83d7b28..25e49bf 100644
--- a/app/assets/javascripts/discourse/lib/to-markdown.js
+++ b/app/assets/javascripts/discourse/lib/to-markdown.js
@@ -291,6 +291,10 @@ export class Tag {
         }
 
         if (src) {
+          if (src.match(/^data:image\/([a-zA-Z]*);base64,([^\"]*)$/)) {
+            return "[image]";
+          }
+
           let alt = attr.alt || pAttr.alt || "";
           const width = attr.width || pAttr.width;
           const height = attr.height || pAttr.height;
diff --git a/test/javascripts/lib/to-markdown-test.js b/test/javascripts/lib/to-markdown-test.js
index bcda89c..3ae081d 100644
--- a/test/javascripts/lib/to-markdown-test.js
+++ b/test/javascripts/lib/to-markdown-test.js
@@ -413,3 +413,9 @@ there is a quote above
 
   assert.equal(toMarkdown(html), markdown.trim());
 });
+
+QUnit.test("strips base64 image URLs", assert => {
+  const html =
+    '<img src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAgAAZABkAAD/7AARRHVja3kAAQAEAAAAPAAA/+4AJkFkb2JlAGTAAAAAAQMAFQQDBgoNAAABywAAAgsAAAJpAAACyf/bAIQABgQEBAUEBgUFBgkGBQYJCwgGBggLDAoKCwoKDBAMDAwMDAwQDA4PEA8ODBMTFBQTExwbGxscHx8fHx8fHx8fHwEHBwcNDA0YEBAYGhURFRofHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8f/8IAEQgAEAAQAwERAAIRAQMRAf/EAJQAAQEBAAAAAAAAAAAAAAAAAAMFBwEAAwEAAAAAAAAAAAAAAAAAAAEDAhAAAQUBAQAAAAAAAAAAAAAAAgABAwQFESARAAIBAwIHAAAAAAAAAAAAAAERAgAhMRIDQWGRocEiIxIBAAAAAAAAAAAAAAAAAAAAIBMBAAMAAQQDAQAAAAAAAAAAAQARITHwQVGBYXGR4f/aAAwDAQACEQMRAAAB0UlMciEJn//aAAgBAQABBQK5bGtFn6pWi2K12wWTRkjb/9oACAECAAEFAvH/2gAIAQMAAQUCIuIJOqRndRiv/9oACAECAgY/Ah//2gAIAQMCBj8CH//aAAgBAQEGPwLWQzwHepfNbcUNfM4tUIbA9QL4AvnxTlAxacpWJReOlf/aAAgBAQMBPyHZDveuCyu4B4lz2lDKto2ca5uclPK0aoq32x8xgTSLeSgbyzT65n//2gAIAQIDAT8hlQjP/9oACAEDAwE/IaE9GcZFJ//aAAwDAQACEQMRAAAQ5F//2gAIAQEDAT8Q1oowKccI3KTdAWkPLw2ssIrwKYUzuJoUJsIHOCoG23ISlja+rU9QvCx//9oACAECAwE/EAuNIiKf/9oACAEDAwE/ECujJzHf7iwHOv5NhK+8efH50z//2Q==" />';
+  assert.equal(toMarkdown(html), "[image]");
+});

GitHub sha: 0cef409d