New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OnlyOffice support generates document key of 0000000000000000000000000000000000000000 for emtpy files #1606
Comments
sorry, I've just notice that 5119990 fixes this |
Sorry, I misread the diff for 5119990 this update introduces the problem rather than fixes it! the new use of obj_id generates a key of all zeros, (as well as a 40 character string which exceeds the stated maximum length of 20 in the OnlyOffice API documentation), whereas the older gen_token generates a unique key even for empty files. Perhaps line 458 should be doc_key = gen_token(20) |
It should be doc id as long as it's not zero. |
@mdovey Did you test in a new installed? |
Possibly it would be a good idea to make a hash from the document id and path. Because only one file can be a a specifc path this should be very very unlikely to collide. |
Ok please check a possible workaround, but i'm not sure if this the best way. I hope a dev can check this. |
Guys, sorry for the delay! I will check it today. |
Here is my patch https://github.com/haiwen/seahub/pull/1616/files, you guys please take a test. @TMHBOFH your workaround is okay, but it's better to add repo_id into that hash stuff. |
My concern with this code is that although the hash function should produce an id with low probability of a clash, there is no such assertion about a sub-string of that id. A better approach would be a hash function which generated a 20 char hexdigest directly (i.e. an 80bit hash) - however, the techniques for this do not look simple (https://crypto.stackexchange.com/questions/3558/are-there-hash-algorithms-with-variable-length-output) I'm afraid I'm not an expert to know if truncating the 32 character string to 20 characters significantly increases the likelihood of clashes. |
Adding obj_id into hash produces new errors, While 2 people work on same shared document and one of them leave onlyoffice calls save callback and obj_id changes. Also document key changes. If one of these users refresh the page now they have 2 different document on onlyoffice but 1 document on seafile. Seafile save this documents to same path. Last exited user will win and his revision will be saved. |
If a file is empty (i.e. file size of 0), for instance if you have created a new file in seafile, the key passed to OnlyOffice is always 0000000000000000000000000000000000000000
For instance the script created looks like:
var config = {
"document": {
"fileType": "docx",
"key": "0000000000000000000000000000000000000000",
"title": "yetanother.docx",
The problem is that this creates a key clash if you attempt to open multiple empty files, as OnlyOffice thinks that these are the same file.
The text was updated successfully, but these errors were encountered: