From 0a1432f047f3299120fc5df26cae19b557dbd997 Mon Sep 17 00:00:00 2001 From: FinnStutzenstein Date: Fri, 4 Aug 2017 14:53:28 +0200 Subject: [PATCH] Fixing strage umlauts when copy text from word --- CHANGELOG | 2 +- openslides/core/static/js/core/pdf.js | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 9503ff587..837db32e3 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -75,7 +75,7 @@ General: - Switched from npm to Yarn [#3188]. - Improved performance for PDF generation significantly (by upgrading to pdfmake 0.1.30) [#3278, #3285]. -- Bugfixes for PDF creation [#3227, #3251, #3279, #3286, #3346, #3347]. +- Bugfixes for PDF creation [#3227, #3251, #3279, #3286, #3346, #3347, #3342]. - Improvements for plugin integration [#3330]. diff --git a/openslides/core/static/js/core/pdf.js b/openslides/core/static/js/core/pdf.js index 3b4ec788a..a565eb9a1 100644 --- a/openslides/core/static/js/core/pdf.js +++ b/openslides/core/static/js/core/pdf.js @@ -119,10 +119,21 @@ angular.module('OpenSlidesApp.core.pdf', []) .factory('HTMLValidizer', function() { var HTMLValidizer = {}; + // In some cases copying from word to OpenSlides results in umlauts + // that are the base letter and then the entity #776; to make the dots + // above the base letter. This breaks the PDF. + HTMLValidizer.replaceMalformedUmlauts = function (text) { + return text.replace(/([aeiouAEIOUy])[\u0308]/g, function (match, baseChar) { + return '&' + baseChar + 'uml;'; + }); + }; + //checks if str is valid HTML. Returns valid HTML if not, //return emptystring if empty HTMLValidizer.validize = function(str) { if (str) { + str = HTMLValidizer.replaceMalformedUmlauts(str); + var a = document.createElement('div'); a.innerHTML = str; angular.forEach(a.childNodes, function (child) {