Fix for issue 6487: Opening BibTex file (doubleclick) from Folder with spaces not working#7551
Conversation
update 2021.3.3
update 2021.3.8
update 2021.3.9
update 2021.3.11
update 2021.3.12
update 2021.3.15
update 2021.3.17
who invoked the method sendMessage(type=SEND_COMMAND_LINE_ARGUMENTS) when double-clicking
tobiasdiez
left a comment
There was a problem hiding this comment.
Thanks a lot for your detailed analysis! The fix looks good to me.
The linked issue also mentions that double clicking a file without having jabref open doesn't work sometimes (if I got the gist right by skimming it). I guess this is not fixed with this PR, right?
| try (Protocol protocol = openNewConnection()) { | ||
| protocol.sendMessage(RemoteMessage.SEND_COMMAND_LINE_ARGUMENTS, args); | ||
|
|
||
| String[] encodedArgs = args.clone(); |
There was a problem hiding this comment.
Can you please put this addition in the protocol.sendMessage so that only the protocol has to worry about decoding/encoding. Also please add a short comment explaining why we need to encode. Thanks!
created a new test in RemoteCommunicationTest
|
Thanks for your acknowledgement! I moved it to Besides, I created a new test case in As @RickVandoorne mentioned:
I tested these three ways to open a Double click while JabRef not running: Double click while JabRef running: "Open library": open.library.mp4 |
| client.sendCommandLineArguments(message.clone()); | ||
|
|
||
| verify(server).handleCommandLineArguments(message); | ||
| } |
There was a problem hiding this comment.
I am wondering whether this test case is appropriate. Not so sure about how to write a test about socket communication.
There was a problem hiding this comment.
Yeah, it's hard to test this. I think, your added test is fine.
| final String[] message = new String[]{"my message"}; | ||
|
|
||
| client.sendCommandLineArguments(message); | ||
| client.sendCommandLineArguments(message.clone()); |
There was a problem hiding this comment.
I would move the clone call to the sendMessage method. It's usually a good practice to not modify parameters passed to a method.
There was a problem hiding this comment.
Done. Thank you for your advice!
Siedlerchr
left a comment
There was a problem hiding this comment.
thanks for the fix! LGTM as well
tobiasdiez
left a comment
There was a problem hiding this comment.
Thanks again for your contribution! Looking forward to your next PR 🚀
* upstream/master: (191 commits) Fix for issue 7416: font size of the preferences dialog does not update with the rest of the GUI. (#7509) Fix school/instituation is printed twice (#7574) Dsiable notarisation until we hae an account for JabRef e.V. (#7572) Fix citation keys unintentionally being overwritten on import (#7443) Fix AuthentificationPlugin not declared in mergedModule (#7570) Suggestions for changes in caching latex free authors (#7301) Add simple Unit Tests (#7542) Fix drag and drop into empty library (#7555) Bump richtextfx from 0.10.4 to 0.10.6 (#7563) Bump pdfbox from 2.0.22 to 2.0.23 (#7561) Bump org.eclipse.jgit (#7560) Bump fontbox from 2.0.22 to 2.0.23 (#7562) Bump guava from 30.1-jre to 30.1.1-jre (#7564) Bump xmpbox from 2.0.22 to 2.0.23 (#7565) Bump hmarr/auto-approve-action from v2.0.0 to v2.1.0 (#7566) Add gource (#7193) UI: Fix for group icon (#7552) Fix for issue 6487: Opening BibTex file (doubleclick) from Folder with spaces not working (#7551) add ability to insert arxivId (#7549) Fixed missing trigger for linked file operations (#7548) ...
Fixes #6487
CHANGELOG.mddescribed in a way that is understandable for the average user (if applicable)Video:
fix6487.mp4
Use
D:\TEST\test whitespace.bibas an example.Double-click it, and I got errors in console as the following:
Therefore, the path was regarded as two files:
D:\TEST\testandwhitespace.bib.Start from
org.jabref.logic.importer.OpenDatabaseto backtrack the dataflow:OpenDatabaseloadDatabasefileToOpenArgumentProcessorimportAndOpenFilesaLeftOverJabRefCLIargsArgumentProcessorargsJabRefMessageHandlerhandleCommandlineArgumentsmessageRemoteListenerServerhandleMessageargumentRemoteListenerServerruninput.getValue()ProtocolreceiveMessageargumentUse logger to print the variable
argument:And I got:
So I think the problem is that when passing the argument
D:\TEST\test whitespace.bib, it will be considered as two arguments because there is a whitespace that serves as a delimiter.I noticed that @zongxian said that a path containing Chinese characters would cause the same error. So the problem is not just related to delimiter, probably about text encoding.
Therefore I encoded the arguments in
RemoteClient.sendCommandLineArgumentsand decoded them inProtocol.receiveMessage.Then I created a binary and tested. Now it works well on my computer (Windows 10 1909).