diff --git a/src/node/handler/ImportHandler.js b/src/node/handler/ImportHandler.js
index 719cb9f88..c25623d76 100644
--- a/src/node/handler/ImportHandler.js
+++ b/src/node/handler/ImportHandler.js
@@ -203,17 +203,6 @@ async function doImport(req, res, padId) {
if (!req.directDatabaseAccess) {
text = await fsp_readFile(destFile, 'utf8');
- /*
- * The
tag needs to be stripped out, otherwise it is appended to the
- * pad.
- *
- * Moreover, when using LibreOffice to convert the file, some classes are
- * added to the tag. This is a quick & dirty way of matching the
- * title and comment it out independently on the classes that are set on it.
- */
- text = text.replace('', '-->');
-
// node on windows has a delay on releasing of the file lock.
// We add a 100ms delay to work around this
if (os.type().indexOf('Windows') > -1) {
diff --git a/src/node/utils/ImportHtml.js b/src/node/utils/ImportHtml.js
index 48ae30087..831b3f53e 100644
--- a/src/node/utils/ImportHtml.js
+++ b/src/node/utils/ImportHtml.js
@@ -36,7 +36,7 @@ exports.setPadHTML = async (pad, html) => {
// below the last line of an import
$('body').append('');
- const doc = $('html')[0];
+ const doc = $('body')[0];
apiLogger.debug('html:');
apiLogger.debug(html);
diff --git a/tests/backend/specs/api/importexport.js b/tests/backend/specs/api/importexport.js
index c8e5444ea..02395eae7 100644
--- a/tests/backend/specs/api/importexport.js
+++ b/tests/backend/specs/api/importexport.js
@@ -56,6 +56,12 @@ const testImports = {
expectedText: '\t1. should be 1\n\ttest\n\t2. should be 2\n\n'
}
*/
+ 'ignoreAnyTagsOutsideBody': {
+ description: 'Content outside body should be ignored',
+ input: 'titleempty
',
+ expectedHTML: 'empty
',
+ expectedText: 'empty\n\n',
+ },
};
describe(__filename, function () {
diff --git a/tests/backend/specs/contentcollector.js b/tests/backend/specs/contentcollector.js
index 156568ab2..3608faed6 100644
--- a/tests/backend/specs/contentcollector.js
+++ b/tests/backend/specs/contentcollector.js
@@ -107,7 +107,12 @@ const tests = {
noteToSelf: "should create a line break but not break numbering -- This is what I can't get working!",
disabled: true,
},
-
+ ignoreAnyTagsOutsideBody: {
+ description: 'Content outside body should be ignored',
+ html: 'titleempty
',
+ expectedLineAttribs: ['+5'],
+ expectedText: ['empty'],
+ },
};
describe(__filename, function () {
@@ -122,7 +127,7 @@ describe(__filename, function () {
it(testObj.description, function (done) {
const $ = cheerio.load(testObj.html); // Load HTML into Cheerio
- const doc = $('html')[0]; // Creates a dom-like representation of HTML
+ const doc = $('body')[0]; // Creates a dom-like representation of HTML
// Create an empty attribute pool
const apool = new AttributePool();
// Convert a dom tree into a list of lines and attribute liens