closes #1706, [PATCH] Item with non-ASCII characters corrupted on save when Show Editor is open
The problem here was that entities weren't properly being encoded as Unicode RTF when the editor was used, because TinyMCE was replacing high characters with HTML entities that were not properly decoded. This is now fixed.
This commit is contained in:
parent
cb1446fdea
commit
c9003f1f40
1 changed files with 7 additions and 4 deletions
|
@ -76,7 +76,6 @@
|
|||
this._htmlToRtfMap = [
|
||||
[/"(\w)/, "“$1"],
|
||||
[/([\w,.?!])"/, "$1”"],
|
||||
[/[\x7F-\uFFFF]/g, function(aChar) { return "\\uc0\\u"+aChar.charCodeAt(0).toString()+" " }],
|
||||
["<p>", ""],
|
||||
["</p>", "\\par "],
|
||||
[/<\/?div[^>]*>/g, ""],
|
||||
|
@ -179,6 +178,7 @@
|
|||
<!-- Sets or returns contents of rich text box -->
|
||||
<property name="value">
|
||||
<getter><![CDATA[
|
||||
const highcharRe = /[\x7F-\uFFFF]/g;
|
||||
var output = this._editor.getContent();
|
||||
|
||||
if(this._format == "RTF") {
|
||||
|
@ -213,9 +213,12 @@
|
|||
for each(var entry in this._htmlToRtfMap) {
|
||||
output = output.replace(entry[0], entry[1], "g");
|
||||
}
|
||||
output = Zotero.Utilities.prototype.trim(output);
|
||||
output = output.replace(" ", " ", "g");
|
||||
output = Zotero.Utilities.prototype.unescapeHTML(output);
|
||||
output = Zotero.Utilities.prototype.trim(output)
|
||||
output = Zotero.Utilities.prototype.unescapeHTML(
|
||||
output.replace(" ", " ", "g"))
|
||||
.replace(highcharRe,
|
||||
function(aChar) { return "\\uc0\\u"+aChar.charCodeAt(0).toString()+" " });
|
||||
|
||||
if(output.substr(-4) == "\\par") output = output.substr(0, output.length-4);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue