Skip to content

"Rename file" fails silently #2 #4527

@stefanct

Description

@stefanct

The "Rename file" feature does not work for me (at least in some instances) in 4.3.1 and current 5.0 master (65a1a03). When that menu entry is clicked the file widget flashes shortly but the context menu remains as if no click happened, and more importantly the file is not renamed but an uncaught exception is thrown:

04:55:15.960 [JavaFX Application Thread] ERROR org.jabref.FallbackExceptionHandler - Uncaught exception occurred in Thread[JavaFX Application Thread,5,main]
java.lang.StringIndexOutOfBoundsException: String index out of range: -4
	at java.lang.String.substring(String.java:1967) ~[?:1.8.0_191]
	at org.jabref.logic.formatter.bibtexfields.RegexFormatter.<init>(RegexFormatter.java:39) ~[JabRef-5.0-dev--snapshot--2018-11-30--master--65a1a03b9.jar:?]
	at org.jabref.logic.formatter.Formatters.getFormatterForModifier(Formatters.java:94) ~[JabRef-5.0-dev--snapshot--2018-11-30--master--65a1a03b9.jar:?]
	at org.jabref.logic.bibtexkeypattern.BracketedPattern.applyModifiers(BracketedPattern.java:389) ~[JabRef-5.0-dev--snapshot--2018-11-30--master--65a1a03b9.jar:?]
	at org.jabref.logic.bibtexkeypattern.BracketedPattern.expandBrackets(BracketedPattern.java:129) ~[JabRef-5.0-dev--snapshot--2018-11-30--master--65a1a03b9.jar:?]
	at org.jabref.logic.util.io.FileUtil.createFileNameFromPattern(FileUtil.java:264) ~[JabRef-5.0-dev--snapshot--2018-11-30--master--65a1a03b9.jar:?]
	at org.jabref.logic.externalfiles.LinkedFileHandler.getSuggestedFileName(LinkedFileHandler.java:113) ~[JabRef-5.0-dev--snapshot--2018-11-30--master--65a1a03b9.jar:?]
	at org.jabref.logic.externalfiles.LinkedFileHandler.findExistingFile(LinkedFileHandler.java:128) ~[JabRef-5.0-dev--snapshot--2018-11-30--master--65a1a03b9.jar:?]
	at org.jabref.gui.fieldeditors.LinkedFileViewModel.performRenameWithConflictCheck(LinkedFileViewModel.java:210) ~[JabRef-5.0-dev--snapshot--2018-11-30--master--65a1a03b9.jar:?]
	at org.jabref.gui.fieldeditors.LinkedFileViewModel.rename(LinkedFileViewModel.java:203) ~[JabRef-5.0-dev--snapshot--2018-11-30--master--65a1a03b9.jar:?]
	at org.jabref.gui.fieldeditors.LinkedFilesEditor.lambda$createContextMenuForFile$393(LinkedFilesEditor.java:222) ~[JabRef-5.0-dev--snapshot--2018-11-30--master--65a1a03b9.jar:?]
[…]
	at java.lang.Thread.run(Thread.java:748) [?:1.8.0_191]

The entry used for testing is the following:

@TechReport{Nie2017,
  author      = {Sen Nie and Ling Liu and Yuefeng Du and Wenkai Zhang},
  title       = {Over-the-Air: How we Remotely Compromised the Gateway, {BCM}, and Autopilot {ECU}s of Tesla Cars},
  institution = {Keen Security Lab of Tencent},
  year        = {2017},
  note        = {Blackhat 2018},
  file        = {:./us-18-Liu-Over-The-Air-How-We-Remotely-Compromised-The-Gateway-Bcm-And-Autopilot-Ecus-Of-Tesla-Cars-wp.pdf:PDF},
  url         = {http://i.blackhat.com/us-18/Thu-August-9/us-18-Liu-Over-The-Air-How-We-Remotely-Compromised-The-Gateway-Bcm-And-Autopilot-Ecus-Of-Tesla-Cars-wp.pdf},
}

No matter what I put into Preferences/Import/"File format pattern" in the settings (I tried various things like [year]-[auth]-[title:regex: :_], \year-\author-\format[Replace("\s,_")]{title} and year-author-title obviously not really knowing what I am doing because GUI and documentation issues (to put it mildly)) all with the same result.
This bug might also be related to #3920 and/or #3990 but probably not.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Done

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions