From fb3341f5c6254db89145ed81256cfe85ae21ab30 Mon Sep 17 00:00:00 2001 From: Papyxulo <110495450+Papyxulo@users.noreply.github.com> Date: Thu, 22 Aug 2024 11:20:50 +0100 Subject: [PATCH] Fix for the #399 (broken url reference links) fix for https://github.com/pwndoc-ng/pwndoc-ng/issues/399 - Fixed the issue with URL's in the reference field not being correctly generated in the docx file (tested in libreoffice and office 365) - Removed odd shading that was being generated in the reference field links (it was displayed in office 365) --- backend/src/lib/report-generator.js | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/backend/src/lib/report-generator.js b/backend/src/lib/report-generator.js index 851437e..d189cff 100644 --- a/backend/src/lib/report-generator.js +++ b/backend/src/lib/report-generator.js @@ -300,14 +300,24 @@ expressions.filters.lines = function(input) { // Creates a hyperlink: {@input | linkTo: 'https://example.com' | p} expressions.filters.linkTo = function(input, url) { - var encodedUrl = encodeURIComponent(url); // fix breaking word with special characters in reference - var encodedInput = encodeURIComponent(input); // fix breaking word with special characters in reference - return ` - HYPERLINK "${encodedUrl}" - - - ${encodedInput} - `; + + // fix breaking word with special characters in reference + var entityencodedurl = url.replace(/&/g, '&').replace(//g, '>').replace(/"/g, '"').replace(/'/g, '''); // encode to prevent xml issues + var entityencodedinput = input.replace(/&/g, '&').replace(//g, '>').replace(/"/g, '"').replace(/'/g, '''); // encode to prevent xml issues + var encodedUrl = encodeURI(entityencodedurl); // encode the uri + var encodedInput = encodeURI(entityencodedinput); // encode the uri + + return ` + + HYPERLINK "${encodedUrl}" + + + + + + ${encodedInput} +`; + } // Loop over the input object, providing acccess to its keys and values: {#findings | loopObject}{key}{value.title}{/findings | loopObject}