feature or bug? rename attachments in zotero 7 beta 21

edited July 21, 2023
Hello! When using the built-in "Rename File from Parent Metadata" function in Zotero 7, I encountered an issue.

If a particular article has only two authors, when I use the function, the attached PDF file name will have some strange characters (as shown in the screenshot, in case of something wrong, here is the URL https://s3.bmp.ovh/imgs/2023/07/21/5ed335bc11338d36.png ). Some editors can display these characters, while others cannot, and it seems that these characters are zero-width characters.

Is this considered a feature or a bug?

https://s3.bmp.ovh/imgs/2023/07/21/5ed335bc11338d36.png

thank you for your time.

P.S. my environments:
windows 10 64 bits
zotero 7 beta24 64bits
  • This will be fixed in an upcoming beta.
  • @dstillman thanks for your reply and time.
  • edited July 26, 2023
    @dstillman
    Sorry to bother you again.

    in my workflow, I need get the author_year, just as the following code,

    ```javascript
    var items = Zotero.getActiveZoteroPane().getSelectedItems();
    //return items;
    let Creators = item._creators;
    let isChinese = /[\u4e00-\u9fa5]+/.test(item.firstCreator);
    let result = "";
    if (isChinese) {
    if (Creators.length == 1) {
    result = Creators[0].lastName + Creators[0].firstName;
    } else if (Creators.length == 2) {
    result = Creators[0].lastName + Creators[0].firstName + joinSeparator + Creators[1].lastName + Creators[1].firstName;
    } else {
    result = Creators[0].lastName + Creators[0].firstName + eta;
    }
    } else {
    result = item.firstCreator;
    }
    return result;
    ```

    select a particular article which has only two authors,
    run the code in zotero -- tools -- developer -- run javascript, make sure to check "Run as async function".

    In the "Return value" window, pressing Ctrl+A, Ctrl+C, and then Ctrl+V in some editor (for example, Notepad++) , some special characters will be revealed, just like the situation of renaming the attachment in zotero7.0.0 beta21, possibly indicating incomplete patching of related bug.
    Additionally, it is unknown if there may be similar problem elsewhere.


    P.S. my run environment:

    windows10 + zotero7.0.0 beta.23


    many thanks.

  • edited July 26, 2023
    The characters are valid Unicode bidirectional isolate characters that are there for a reason — the bug was that they appeared in some contexts where they should. The output of the Run JavaScript window obviously isn't any sort of supported context, so you're on your own for that. If the program where you're using the string can't handle the characters, you'll need strip them from the firstCreator value.

    https://github.com/zotero/zotero/blob/a1f49e11d583c57e05a622aa24878d329a571d4c/chrome/content/zotero/xpcom/data/item.js#L248
  • thanks. I will have a try.
Sign In or Register to comment.