From 64cf06389d7bd428c592c995232a8dc0491090d2 Mon Sep 17 00:00:00 2001 From: David Merfield Date: Wed, 27 Mar 2024 13:37:11 +0000 Subject: [PATCH] Update dependencies (#782) * Run npm audit fix * Updates marked * Updates spritesmith * Updates simple git * Updates cheerio * Removes blessed * Bumps mailgun * Bumps gifsicle * Bumps pngquant * Bumps mozjpeg * Bumps mozjpeg * Bumps mailgun * Updates usage of marked * Fixes org converter * Fixes markdown and rtf converters * Updates usage of cheerio * Fixes ODT * Fixes encodeXML * Fixes video embed tests * Fixes gdoc tests * Fixes docx converter * Updates git client * Updates spritesmith * Revert "Updates spritesmith" This reverts commit 6df80ca6366e11606b0d7bced2363957782fdcc2. --- app/blog/render/retrieve/absoluteURLs.js | 4 +- app/blog/render/retrieve/encodeXML.js | 13 +- app/blog/render/retrieve/tests/encodeXML.js | 4 +- app/build/converters/docx/index.js | 15 +- .../converters/gdoc/tests/metadata.gdoc.html | 2 +- .../converters/markdown-without-pandoc.js | 8 +- app/build/converters/markdown/footnotes.js | 2 +- app/build/converters/markdown/indentation.js | 16 +- app/build/converters/odt/index.js | 223 +- app/build/converters/odt/tests/index.js | 7 +- app/build/converters/org/convert.js | 9 +- .../org/tests/examples/images.org.html | 2 +- .../org/tests/examples/metadata.org.html | 2 +- .../org/tests/examples/yaml.org.html | 2 +- app/build/converters/rtf/index.js | 7 +- app/build/dependencies/index.js | 4 +- app/build/plugins/image/tests.js | 10 +- app/build/plugins/index.js | 6 +- app/build/plugins/videoEmbeds/bandcamp.js | 2 +- app/build/plugins/videoEmbeds/tests/index.js | 4 +- app/build/plugins/videoEmbeds/youtube.js | 2 +- app/build/prepare/index.js | 12 +- app/build/prepare/teaser.js | 26 +- app/build/prepare/tests/internalLinks.js | 12 +- app/build/prepare/tests/summary.js | 29 +- app/build/prepare/tests/title.js | 26 +- app/build/thumbnail/candidates.js | 2 +- app/clients/git/remove.js | 4 +- app/clients/git/tests/authenticate.js | 31 +- app/clients/git/tests/setup/setClientToGit.js | 6 +- app/clients/git/tests/sync.js | 2 +- .../import/sources/micro.blog/index.js | 4 +- .../import/sources/write.as/index.js | 17 +- app/documentation/developers.js | 6 +- app/documentation/news.js | 4 +- app/documentation/notes.js | 8 +- app/documentation/questions/render.js | 4 +- app/documentation/templates.js | 4 +- app/helper/email/index.js | 4 +- app/helper/express-mustache/index.js | 6 +- package-lock.json | 17871 +++++++++------- package.json | 17 +- todo.txt | 2 + 43 files changed, 9855 insertions(+), 8586 deletions(-) diff --git a/app/blog/render/retrieve/absoluteURLs.js b/app/blog/render/retrieve/absoluteURLs.js index fcae3c746bf..9fa3a7b7c84 100644 --- a/app/blog/render/retrieve/absoluteURLs.js +++ b/app/blog/render/retrieve/absoluteURLs.js @@ -20,7 +20,7 @@ Use it like this: var cheerio = require("cheerio"); var debug = require("debug")("blot:render:absoluteURLs"); -function absoluteURLs(base, $) { +function absoluteURLs (base, $) { try { $("[href], [src]").each(function () { var href = $(this).attr("href"); @@ -51,7 +51,7 @@ module.exports = function (req, callback) { text = render(text); - var $ = cheerio.load(text); + var $ = cheerio.load(text, null, false); text = absoluteURLs(base, $); text = $.html(); diff --git a/app/blog/render/retrieve/encodeXML.js b/app/blog/render/retrieve/encodeXML.js index b6c291861fb..7587653adc0 100644 --- a/app/blog/render/retrieve/encodeXML.js +++ b/app/blog/render/retrieve/encodeXML.js @@ -8,8 +8,9 @@ var cheerio = require("cheerio"); // Removes everything forbidden by XML 1.0 specifications, // plus the unicode replacement character U+FFFD -function removeXMLInvalidChars(string) { - var regex = /((?:[\0-\x08\x0B\f\x0E-\x1F\uFFFD\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]))/g; +function removeXMLInvalidChars (string) { + var regex = + /((?:[\0-\x08\x0B\f\x0E-\x1F\uFFFD\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]))/g; return string.replace(regex, ""); } @@ -22,7 +23,13 @@ module.exports = function (req, callback) { text = render(text); try { - $ = cheerio.load(text); + $ = cheerio.load( + text, + { + decodeEntities: false + }, + false + ); $ = absoluteURLs(req.protocol + "://" + req.get("host"), $); $("script").remove(); xml = $.html(); diff --git a/app/blog/render/retrieve/tests/encodeXML.js b/app/blog/render/retrieve/tests/encodeXML.js index fe5259ccda9..1301e8d1183 100644 --- a/app/blog/render/retrieve/tests/encodeXML.js +++ b/app/blog/render/retrieve/tests/encodeXML.js @@ -9,7 +9,7 @@ describe("encodeXML", function () { protocol: "http", get: function () { return "example.com"; - }, + } }; }); @@ -34,7 +34,7 @@ describe("encodeXML", function () { encodeXML(this.request, function (err, lambda) { result = mustache.render(template, { encodeXML: lambda }); - expect(result).toEqual("& foo (便利"); + expect(result).toEqual("& foo (便利"); done(); }); }); diff --git a/app/build/converters/docx/index.js b/app/build/converters/docx/index.js index 5e1c6fce920..9f2ae9cbfef 100644 --- a/app/build/converters/docx/index.js +++ b/app/build/converters/docx/index.js @@ -81,7 +81,13 @@ function read (blog, path, options, callback) { } fs.readFile(outPath, "utf-8", function (err, html) { - var $ = cheerio.load(html, { decodeEntities: false }); + // remove everything between '' including those comments + html = html.replace( + //g, + "" + ); + + var $ = cheerio.load(html, { decodeEntities: false }, false); // all p that contain possible metadata are checked until one is encountered that does not // p that are entirely bold are turned into h tags @@ -89,6 +95,11 @@ function read (blog, path, options, callback) { var metadata = {}; + // remove