From d3b036d8823a652e2d77bacb6b418f958b7d83a6 Mon Sep 17 00:00:00 2001 From: azivner Date: Sun, 13 Aug 2017 22:35:04 -0400 Subject: [PATCH] HTML tags which are not converted to notecase formattings are stripped - that way notecase webapp doesn't save stuff not readable by notecase desktop. Also bugfix in parsing links --- static/js/html2notecase.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/static/js/html2notecase.js b/static/js/html2notecase.js index 03ba143b8..b20775d37 100644 --- a/static/js/html2notecase.js +++ b/static/js/html2notecase.js @@ -12,9 +12,9 @@ function html2notecase(contents, note) { note.images = []; while (index < contents.length) { - let found = false; - if (contents[index] == '<') { + let found = false; + let curContent = contents.substr(index); let endOfTag = curContent.indexOf('>'); @@ -87,7 +87,7 @@ function html2notecase(contents, note) { } } - let match = /]+?href="([^"]+?)"[^>]+?>([^<]+?)<\/a>/.exec(curContent); + let match = /^]+?href="([^"]+?)"[^>]+?>([^<]+?)<\/a>/.exec(curContent); if (match != null) { note.links.push({ @@ -114,9 +114,12 @@ function html2notecase(contents, note) { // if (match != null) { // } - } - if (!found) { + if (!found) { + contents = contents.substr(0, index) + contents.substr(index + endOfTag + 1); + } + } + else { index++; } }