# HG changeset patch # User Mike Becker # Date 1765916597 -3600 # Node ID 39644afa38086c5c0f66f59c4e535ab67ddd88da # Parent a629b831c96deb9549781a914a6287b715a27a4d fix that backslashes in commit messages were not escaped in the JSON resolves #788 diff -r a629b831c96d -r 39644afa3808 CHANGELOG --- a/CHANGELOG Sun Nov 30 22:55:34 2025 +0100 +++ b/CHANGELOG Tue Dec 16 21:23:17 2025 +0100 @@ -1,3 +1,7 @@ +Version 1.1.2 - 2025-12-15 + +- Fix that backslashes in commit messages were not escaped in the JSON + Version 1.1.1 - 2025-10-09 - Fix that only the main branch was considered in git repositories diff -r a629b831c96d -r 39644afa3808 Makefile --- a/Makefile Sun Nov 30 22:55:34 2025 +0100 +++ b/Makefile Tue Dec 16 21:23:17 2025 +0100 @@ -21,7 +21,7 @@ # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -VERSION=1.1.1 +VERSION=1.1.2 all: compile FORCE diff -r a629b831c96d -r 39644afa3808 src/html.cpp --- a/src/html.cpp Sun Nov 30 22:55:34 2025 +0100 +++ b/src/html.cpp Tue Dec 16 21:23:17 2025 +0100 @@ -394,15 +394,19 @@ static_cast(ymd.day())); // Utility function to escape strings in JSON - auto escape_json = [](std::string str) static { - size_t pos = str.find('\"'); - if (pos == std::string::npos) return str; - std::string escaped = std::move(str); - do { - escaped.replace(pos, 1, "\\\""); - pos += 2; - } while ((pos = escaped.find('\"', pos)) != std::string::npos); - return escaped; + auto escape_json = [](std::string raw) static { + using std::string_view_literals::operator ""sv; + auto replace_all = [](std::string str, char chr, std::string_view repl) static { + size_t pos = str.find(chr); + if (pos == std::string::npos) return str; + std::string result = std::move(str); + do { + result.replace(pos, 1, repl); + pos += repl.length(); + } while ((pos = result.find(chr, pos)) != std::string::npos); + return result; + }; + return replace_all(replace_all(std::move(raw), '\\', "\\\\"), '\"', "\\\""sv); }; // Build a JSON object of commit summaries diff -r a629b831c96d -r 39644afa3808 src/main.cpp --- a/src/main.cpp Sun Nov 30 22:55:34 2025 +0100 +++ b/src/main.cpp Tue Dec 16 21:23:17 2025 +0100 @@ -38,7 +38,7 @@ using namespace std::chrono; -static constexpr auto program_version = "1.1.1"; +static constexpr auto program_version = "1.1.2"; static void print_help() { fputs(