From 7aeb4ae8b37b4f607dd8903dd71b20c9012c9e24 Mon Sep 17 00:00:00 2001 From: Tim Storm Date: Wed, 23 Jul 2025 17:58:22 +0200 Subject: [PATCH 1/3] Add usenix.org translator Fix issue where BibTeX escapes were present in title metadata. --- usenix.org.js | 158 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 158 insertions(+) create mode 100644 usenix.org.js diff --git a/usenix.org.js b/usenix.org.js new file mode 100644 index 00000000000..39648034c5f --- /dev/null +++ b/usenix.org.js @@ -0,0 +1,158 @@ +{ + "translatorID": "b97462fa-f20b-4a1e-8a73-3a434a81518b", + "label": "usenix.org", + "creator": "Tim Leonhard Storm", + "target": "^https://www\\.usenix\\.org/conference/.*/presentation", + "minVersion": "5.0", + "maxVersion": "", + "priority": 100, + "inRepository": true, + "translatorType": 4, + "browserSupport": "gcsibv", + "lastUpdated": "2025-07-23 15:57:59" +} + +/* + ***** BEGIN LICENSE BLOCK ***** + + Copyright © 2025 Tim Leonhard Storm + + This file is part of Zotero. + + Zotero is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Zotero is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with Zotero. If not, see . + + ***** END LICENSE BLOCK ***** +*/ +/* Remove pairs of unescaped braces (note that braces in title are quite unlikely anyway) */ +function stripAllUnescapedBraces(s) { + let prev; + do { + prev = s; + s = s.replace(/(^|[^\\])(\{(.*?)\})/g, (_, before, full, content) => before + content); + } while (s !== prev); + // Unescape \{ and \} to { and } + return s.replace(/\\([{}])/g, '$1'); +} + + +async function scrape(doc, url = doc.location.href) { + let translator = Zotero.loadTranslator('web'); + // Embedded Metadata + translator.setTranslator('951c027d-74ac-47d4-a107-9c3069ab7b48'); + translator.setDocument(doc); + translator.setHandler('itemDone', (_obj, item) => { + item.title = stripAllUnescapedBraces(item.title); + item.complete(); + }); + translator.translate(); +} + +function detectWeb(doc, url) { + if (url.includes('/presentation/')) { + return 'conferencePaper'; + } + return false; +} + +async function doWeb(doc, url) { + if (detectWeb(doc, url)) { + await scrape(await requestDocument(url)); + } +} + +/** BEGIN TEST CASES **/ +var testCases = [ + { + "type": "web", + "url": "https://google.com/", + "detectedItemType": false, + "items": [] + }, + { + "type": "web", + "url": "https://www.usenix.org/conference/pepr25/presentation/sharma", + "detectedItemType": "conferencePaper", + "items": [ + { + "itemType": "journalArticle", + "title": "Verifying Humanness: Personhood Credentials for the Digital Identity Crisis", + "creators": [ + { + "firstName": "Tanusree", + "lastName": "Sharma", + "creatorType": "author" + } + ], + "date": "2025", + "language": "en", + "libraryCatalog": "www.usenix.org", + "shortTitle": "Verifying Humanness", + "url": "https://www.usenix.org/conference/pepr25/presentation/sharma", + "attachments": [ + { + "title": "Snapshot", + "mimeType": "text/html" + } + ], + "tags": [], + "notes": [], + "seeAlso": [] + } + ] + }, + { + "type": "web", + "url": "https://www.usenix.org/conference/usenixsecurity18/presentation/bock", + "items": [ + { + "itemType": "conferencePaper", + "title": "Return Of Bleichenbacher’s Oracle Threat (ROBOT)", + "creators": [ + { + "firstName": "Hanno", + "lastName": "Böck", + "creatorType": "author" + }, + { + "firstName": "Juraj", + "lastName": "Somorovsky", + "creatorType": "author" + }, + { + "firstName": "Craig", + "lastName": "Young", + "creatorType": "author" + } + ], + "date": "2018", + "ISBN": "9781939133045", + "conferenceName": "27th USENIX Security Symposium (USENIX Security 18)", + "language": "en", + "libraryCatalog": "www.usenix.org", + "pages": "817-849", + "url": "https://www.usenix.org/conference/usenixsecurity18/presentation/bock", + "attachments": [ + { + "title": "Full Text PDF", + "mimeType": "application/pdf" + } + ], + "tags": [], + "notes": [], + "seeAlso": [] + } + ] + } +] +/** END TEST CASES **/ From 79098b044ed928ff00b9206b5322941f393770bf Mon Sep 17 00:00:00 2001 From: Tim Storm Date: Wed, 23 Jul 2025 18:12:52 +0200 Subject: [PATCH 2/3] fix lint --- usenix.org.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/usenix.org.js b/usenix.org.js index 39648034c5f..af539af574f 100644 --- a/usenix.org.js +++ b/usenix.org.js @@ -9,7 +9,7 @@ "inRepository": true, "translatorType": 4, "browserSupport": "gcsibv", - "lastUpdated": "2025-07-23 15:57:59" + "lastUpdated": "2025-07-23 16:12:34" } /* @@ -46,7 +46,7 @@ function stripAllUnescapedBraces(s) { } -async function scrape(doc, url = doc.location.href) { +async function scrape(doc) { let translator = Zotero.loadTranslator('web'); // Embedded Metadata translator.setTranslator('951c027d-74ac-47d4-a107-9c3069ab7b48'); From ff37493d56082845e4fa0fd002ab1edef2a394fd Mon Sep 17 00:00:00 2001 From: Tim Storm Date: Tue, 29 Jul 2025 18:47:26 +0200 Subject: [PATCH 3/3] fix some formatting issues --- usenix.org.js => USENIX.js | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) rename usenix.org.js => USENIX.js (94%) diff --git a/usenix.org.js b/USENIX.js similarity index 94% rename from usenix.org.js rename to USENIX.js index af539af574f..fdd76f8fbcb 100644 --- a/usenix.org.js +++ b/USENIX.js @@ -1,6 +1,6 @@ { "translatorID": "b97462fa-f20b-4a1e-8a73-3a434a81518b", - "label": "usenix.org", + "label": "USENIX", "creator": "Tim Leonhard Storm", "target": "^https://www\\.usenix\\.org/conference/.*/presentation", "minVersion": "5.0", @@ -9,7 +9,7 @@ "inRepository": true, "translatorType": 4, "browserSupport": "gcsibv", - "lastUpdated": "2025-07-23 16:12:34" + "lastUpdated": "2025-07-29 16:45:18" } /* @@ -35,6 +35,7 @@ ***** END LICENSE BLOCK ***** */ /* Remove pairs of unescaped braces (note that braces in title are quite unlikely anyway) */ + function stripAllUnescapedBraces(s) { let prev; do { @@ -66,19 +67,11 @@ function detectWeb(doc, url) { } async function doWeb(doc, url) { - if (detectWeb(doc, url)) { - await scrape(await requestDocument(url)); - } + await scrape(await requestDocument(url)); } /** BEGIN TEST CASES **/ var testCases = [ - { - "type": "web", - "url": "https://google.com/", - "detectedItemType": false, - "items": [] - }, { "type": "web", "url": "https://www.usenix.org/conference/pepr25/presentation/sharma",