1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-09-16 08:56:40 +02:00

Html entity encoding

This commit is contained in:
Laurent Cozic
2017-07-26 20:00:52 +01:00
parent f80263ab71
commit 3fad338e28
3 changed files with 4266 additions and 4 deletions

View File

@@ -19,6 +19,8 @@ import { BaseScreenComponent } from 'lib/components/base-screen.js';
import { dialogs } from 'lib/dialogs.js';
import { globalStyle } from 'lib/components/global-style.js';
import DialogBox from 'react-native-dialogbox';
const Entities = require('html-entities').AllHtmlEntities;
const htmlentities = (new Entities()).encode;
const styleObject = {
titleTextInput: {
@@ -383,10 +385,10 @@ class NoteScreenComponent extends BaseScreenComponent {
renderer.link = function (href, title, text) {
if (Resource.isResourceUrl(href)) {
return '[Resource not yet supported: ' + href + ']'; // TODO: add title
return '[Resource not yet supported: ' + htmlentities(text) + ']';
} else {
const js = "postMessage(" + JSON.stringify(href) + "); return false;";
let output = "<a title='" + title + "' href='#' onclick='" + js + "'>" + text + '</a>';
let output = "<a title='" + htmlentities(title) + "' href='#' onclick='" + js + "'>" + htmlentities(text) + '</a>';
return output;
}
}
@@ -401,11 +403,11 @@ class NoteScreenComponent extends BaseScreenComponent {
const r = this.state.resources[resourceId];
if (r.mime == 'image/png' || r.mime == 'image/jpg' || r.mime == 'image/gif') {
const src = 'data:' + r.mime + ';base64,' + r.base64;
let output = '<img src="' + src + '"/>';
let output = '<img title="' + htmlentities(title) + '" src="' + src + '"/>';
return output;
}
return '[Image: ' + r.title + '(' + r.mime + ')]';
return '[Image: ' + htmlentities(r.title) + '(' + htmlentities(r.mime) + ')]';
}
let html = note ? '<style>' + normalizeCss + "\n" + css + '</style>' + marked(body, { gfm: true, breaks: true, renderer: renderer }) : '';
@@ -422,6 +424,8 @@ class NoteScreenComponent extends BaseScreenComponent {
html = '<body onscroll="postMessage(\'bodyscroll:\' + document.body.scrollTop);">' + html + scriptHtml + '</body>';
console.info(html);
return html;
}

View File

@@ -10,6 +10,7 @@
},
"dependencies": {
"form-data": "^2.1.4",
"html-entities": "^1.2.1",
"moment": "^2.18.1",
"query-string": "4.3.4",
"react": "16.0.0-alpha.12",

4257
ReactNativeClient/yarn.lock Normal file

File diff suppressed because it is too large Load Diff