-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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?
@@ -52,7 +54,13 @@ public boolean ping() { | |||
*/ | |||
public boolean sendCommandLineArguments(String[] args) { | |||
try (Protocol protocol = openNewConnection()) { | |||
protocol.sendMessage(RemoteMessage.SEND_COMMAND_LINE_ARGUMENTS, args); | |||
|
|||
String[] encodedArgs = args.clone(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
final String[] message = new String[]{"D:\\T EST\\测试te st.bib"}; | ||
|
||
// will be encoded as "D%3A%5CT+EST%5C%E6%B5%8B%E8%AF%95te+st.bib" | ||
client.sendCommandLineArguments(message.clone()); | ||
|
||
verify(server).handleCommandLineArguments(message); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it's hard to test this. I think, your added test is fine.
@@ -51,7 +51,7 @@ void pingReturnsTrue() throws IOException, InterruptedException { | |||
void commandLineArgumentSinglePassedToServer() { | |||
final String[] message = new String[]{"my message"}; | |||
|
|||
client.sendCommandLineArguments(message); | |||
client.sendCommandLineArguments(message.clone()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Thank you for your advice!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for the fix! LGTM as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.md
described in a way that is understandable for the average user (if applicable)Video:
fix6487.mp4
Use
D:\TEST\test whitespace.bib
as an example.Double-click it, and I got errors in console as the following:
Therefore, the path was regarded as two files:
D:\TEST\test
andwhitespace.bib
.Start from
org.jabref.logic.importer.OpenDatabase
to backtrack the dataflow:OpenDatabase
loadDatabase
fileToOpen
ArgumentProcessor
importAndOpenFiles
aLeftOver
JabRefCLI
args
ArgumentProcessor
args
JabRefMessageHandler
handleCommandlineArguments
message
RemoteListenerServer
handleMessage
argument
RemoteListenerServer
run
input.getValue()
Protocol
receiveMessage
argument
Use 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.sendCommandLineArguments
and decoded them inProtocol.receiveMessage
.Then I created a binary and tested. Now it works well on my computer (Windows 10 1909).