From 44c5450b28a8c66bbbbbc91674e7c244b10f8a7d Mon Sep 17 00:00:00 2001 From: DominikDoom Date: Fri, 6 Oct 2023 14:54:29 +0200 Subject: [PATCH] Fix special characters breaking wiki link urls --- javascript/_utils.js | 7 +++---- javascript/tagAutocomplete.js | 2 ++ 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/javascript/_utils.js b/javascript/_utils.js index 19de9ad..9a93104 100644 --- a/javascript/_utils.js +++ b/javascript/_utils.js @@ -1,6 +1,7 @@ // Utility functions for tag autocomplete // Parse the CSV file into a 2D array. Doesn't use regex, so it is very lightweight. +// We are ignoring newlines in quote fields since we expect one-line entries and parsing would break for unclosed quotes otherwise function parseCSV(str) { const arr = []; let quote = false; // 'true' means we're inside a quoted field @@ -22,12 +23,10 @@ function parseCSV(str) { // If it's a comma and we're not in a quoted field, move on to the next column if (cc == ',' && !quote) { ++col; continue; } - // If it's a newline (CRLF) and we're not in a quoted field, skip the next character - // and move on to the next row and move to column 0 of that new row + // If it's a newline (CRLF), skip the next character and move on to the next row and move to column 0 of that new row if (cc == '\r' && nc == '\n') { ++row; col = 0; ++c; quote = false; continue; } - // If it's a newline (LF or CR) and we're not in a quoted field, - // move on to the next row and move to column 0 of that new row + // If it's a newline (LF or CR) move on to the next row and move to column 0 of that new row if (cc == '\n') { ++row; col = 0; quote = false; continue; } if (cc == '\r') { ++row; col = 0; quote = false; continue; } diff --git a/javascript/tagAutocomplete.js b/javascript/tagAutocomplete.js index 87b09b5..fe6d759 100644 --- a/javascript/tagAutocomplete.js +++ b/javascript/tagAutocomplete.js @@ -680,6 +680,8 @@ function addResultsToList(textArea, results, tagword, resetList) { linkPart = linkPart.split("[")[0] } + linkPart = encodeURIComponent(linkPart); + // Set link based on selected file let tagFileNameLower = tagFileName.toLowerCase(); if (tagFileNameLower.startsWith("danbooru")) {