Skip to content

Commit

Permalink
Adding multiple tags support. HTML support (sanitizing) for notes and…
Browse files Browse the repository at this point in the history
… annotations.
  • Loading branch information
frianasoa committed Dec 7, 2023
1 parent f71254a commit 05ba9ab
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 26 deletions.
57 changes: 39 additions & 18 deletions core/format.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,25 +126,26 @@ Format = {
{
annotationtext = "";
}
annotationtext = this.escapehtml(annotationtext);

var contents = "‟"+annotationtext+"” ("+Format.creatorshort(item)+" "+Format.year(item)+", p. "+note["annotationPageLabel"]+")";
if(!this.isvalidxhtml(annotationtext))
{
annotationtext = this.escapehtml(annotationtext);
}

/**
Not allow html in comments from pdf for now;
*/
// comment = Zotero.ZeNotes.Filter.apply(comment, selectors);
var contents = "‟"+annotationtext+"” ("+Format.creatorshort(item)+" "+Format.year(item)+", p. "+note["annotationPageLabel"]+")";

var comment = note["annotationComment"];




if(comment==null)
{
comment = "";
}

// comment = this.escapehtml(comment);
if(!this.isvalidxhtml(comment))
{
comment = this.escapehtml(comment);
}

comment = comment.split("\n").join("<br/>\n");

var annotationpage = JSON.parse(note["annotationPosition"])["pageIndex"];
Expand Down Expand Up @@ -179,14 +180,6 @@ Format = {
filekey: Format.filekey(item),
}
return line;

// for(c in notes)
// {
// Check later
// notes[c] = this.xmlescape(notes[c]);
// }

// return Object.assign({}, line, notes);
},

year(item) {
Expand Down Expand Up @@ -296,6 +289,34 @@ Format = {
return filenames;
},

isvalidxhtml(txt)
{
txt = "<div>"+txt+"</div>"
var r = true;
var parser = null;
if (Zotero.platformMajorVersion >= 102) {
parser = new DOMParser();
}
else
{
parser = Components.classes['@mozilla.org/xmlextras/domparser;1'].createInstance(Components.interfaces.nsIDOMParser);
}

try {
var doc = parser.parseFromString(txt, 'application/xhtml+xml');
const errorNode = doc.querySelector("parsererror");
if(errorNode)
{
r = false;
}
}
catch (error) {
alert(error);
r = false
}
return r;
},

escapehtml(s)
{
return s
Expand Down
2 changes: 1 addition & 1 deletion install.rdf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<Description about="urn:mozilla:install-manifest">
<em:id>[email protected]</em:id>
<em:name>ZeNotes</em:name>
<em:version>0.4.8</em:version>
<em:version>0.4.9</em:version>
<em:multiprocessCompatible>true</em:multiprocessCompatible>
<em:updateURL>https://raw.githubusercontent.com/frianasoa/zenotes/main/zenote-update.json</em:updateURL>
<em:homepageURL>https://github.com/frianasoa/zenotes</em:homepageURL>
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"manifest_version": 2,
"name": "Ze Notes",
"version": "0.4.8",
"version": "0.4.9",
"description": "Advanced notes manager",
"homepage_url": "https://github.com/frianasoa/zenotes",
"author": "Fanantenana Rianasoa Andriariniaina",
Expand Down
6 changes: 3 additions & 3 deletions zenote-update.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
"[email protected]": {
"updates": [
{
"version": "0.4.8",
"update_link": "https://github.com/frianasoa/Ze-Notes/releases/download/v0.4.8/zenotes-v0.4.8.xpi",
"update_hash": "sha256:fd0e88e56b4d3c838344ceb7a78f2c8a5971972497b28f7075852873fda93fc6",
"version": "0.4.9",
"update_link": "https://github.com/frianasoa/Ze-Notes/releases/download/v0.4.9/zenotes-v0.4.9.xpi",
"update_hash": "sha256:117690ec9851fc41e1fe96430bfaf661d0b8719918cbde92258501ee69f1f6bd",
"applications": {
"gecko": {
"strict_min_version": "60.0"
Expand Down
6 changes: 3 additions & 3 deletions zenote-update.rdf
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
<rdf:Seq>
<rdf:li>
<rdf:Description>
<ns1:version>0.4.8</ns1:version>
<ns1:version>0.4.9</ns1:version>
<ns1:targetApplication>
<rdf:Description>
<ns1:id>[email protected]</ns1:id>
<ns1:minVersion>5.0.0</ns1:minVersion>
<ns1:maxVersion>6.*</ns1:maxVersion>
<ns1:updateLink>https://github.com/frianasoa/Ze-Notes/releases/download/v0.4.8/zenotes-v0.4.8.xpi</ns1:updateLink>
<ns1:updateLink>https://github.com/frianasoa/Ze-Notes/releases/download/v0.4.9/zenotes-v0.4.9.xpi</ns1:updateLink>
</rdf:Description>
</ns1:targetApplication>

Expand All @@ -20,7 +20,7 @@
<ns1:id>[email protected]</ns1:id>
<ns1:minVersion>4.999</ns1:minVersion>
<ns1:maxVersion>6.*</ns1:maxVersion>
<ns1:updateLink>https://github.com/frianasoa/Ze-Notes/releases/download/v0.4.8/zenotes-v0.4.8.xpi</ns1:updateLink>
<ns1:updateLink>https://github.com/frianasoa/Ze-Notes/releases/download/v0.4.9/zenotes-v0.4.9.xpi</ns1:updateLink>
</rdf:Description>
</ns1:targetApplication>

Expand Down

0 comments on commit 05ba9ab

Please sign in to comment.