Skip to content
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

Key generator regex() function not handling character classes #6892

Closed
1 task done
jonathan-g opened this issue Sep 8, 2020 · 3 comments · Fixed by #6989
Closed
1 task done

Key generator regex() function not handling character classes #6892

jonathan-g opened this issue Sep 8, 2020 · 3 comments · Fixed by #6989
Labels
bug Confirmed bugs or reports that are very likely to be bugs keygenerator

Comments

@jonathan-g
Copy link

Summary

the regex() operator in the citation key generator is not handling character classes ([<characters>]) correctly.

JabRef Version

JabRef version 5.1--2020-08-30--e023aa0 on Windows 10 10.0 amd64 with Java 14.0.2

Description

When the regular expression in the regex() operator includes a character class ([<characters>]), the operator returns an empty string instead of replacing matched expressions with the replacement string.

Steps to reproduce the behavior:

Consider this entry:

@Article{gilligan:2020:Wickedness.ManagingComplex,
  author       = {Gilligan, Jonathan M. and Vandenbergh, M. P.},
  date         = {2020},
  journaltitle = {Vanderbilt Law Review},
  title        = {Beyond Wickedness: Managing Complex Systems and Climate Change},
}
  1. Set the default citation key generator expression in Options/Preferences to
    [auth:(anon):lower]:[year:lower]:[shorttitle:regex(":+",".")]
    
    and leave the generators for specific types blank.
  2. Regenerate the key. It gives the key as above: gilligan:2020:Wickedness.ManagingComplex,
  3. Now change set the default key generator expression in Options/Preferences to
    [auth:(anon):lower]:[year:lower]:[shorttitle:regex("[:]+",".")]
    
    or
    [auth:(anon):lower]:[year:lower]:[shorttitle:regex("[^A-Za-z0-9]+",".")]
    
  4. Regenerate the key again. It gives gilligan:2020: (the title portion is empty).

When I look at the JabRef event log, it's empty.

@k3KAW8Pnf7mkmdSMPHz27
Copy link
Sponsor Member

Thank you for the very detailed description @jonathan-g !
I'll look into this but I don't think the main issue is with the regex modifier.

@Siedlerchr , I believe this will be fixed in #6706 (because CitationKeyGenerator doesn't parse brackets correctly). This is the relevant test case in the PR that fails

I can add a PR for this particular issue anyway, since there should have been an error message in the log and without looking at it in more detail I don't know why there isn't.

@Siedlerchr Siedlerchr added the bug Confirmed bugs or reports that are very likely to be bugs label Sep 12, 2020
@Siedlerchr
Copy link
Member

@k3KAW8Pnf7mkmdSMPHz27 Is this issue now fixed?

@k3KAW8Pnf7mkmdSMPHz27
Copy link
Sponsor Member

@Siedlerchr no, not yet. I have not published a branch for this issue yet

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Confirmed bugs or reports that are very likely to be bugs keygenerator
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants