ropensci-archive / rorcid

:warning: ARCHIVED :warning: A programmatic interface the Orcid.org API
Other
109 stars 13 forks source link

Minor tweak in extract_bibtex() #92

Closed RLumSK closed 3 years ago

RLumSK commented 3 years ago

Fix wrongly formatted BibTeX strings that could occur under particular circumstances.

Description

This PR addresses two issues I became aware of while using a script to extract ORCID records that was working flawlessly before but crashed out of a sudden:

  1. In the original version of the parser in extract_bibtext() I used nchar() to count the number of characters in the already extracted BibTeX string to correct the final line of the BibTeX entry. The default partial matching mode is nchar(...,type = "chars"). I believe that due to recent changes in the UTF-8 character handling in R, the number nchar() returns changed for some cases (as it is not the some if nchar(..., type = "bytes"). In consequence, instead of having a nice ending of a BibTeX record, the record was even wrongly formated with a double }}. Regardless the cause, my handling of this matter was wrong in the first place, because what I wanted to do (but did not) was nchar(..., type = "width"). I corrected the code accordingly.
  2. While running the related test, it turned out that the put code I had used does not exist anymore, I added a working put code.

I tested the fix with R-devel and R-release.

Related Issue

Nothing I am aware of.

Example

The current version:

x <- strsplit(x = orcid_auth(), " ")[[1]][2]
Sys.setenv(ORCID_TOKEN = x)
aa <- rorcid::orcid_citations(orcid = "0000-0002-0734-2199", put_code = "77226586")
aa$citation

The last characters show

,}\n}" 

while it should read (the new behaviour after the fix).

,\n}" 
RLumSK commented 3 years ago

@sckott Sorry for being an idiot, but I guess I don't understand why the GitHub Actions do not pass here. After re-recording the cassette it works just fine my computer with the tests, but here something seems to be missing regarding the ORCID authentication. Would you mind helping me out here?

sckott commented 3 years ago

thanks @RLumSK !

wrt checks not passing, secrets are not available on pull requests - see e.g., https://github.com/ropensci/rorcid/pull/92/checks?check_run_id=2643315766#step:10:106

i'll have a look

RLumSK commented 3 years ago

wrt checks not passing, secrets are not available on pull requests - see, e.g., https://github.com/ropensci/rorcid/pull/92/checks?check_run_id=2643315766#step:10:106

@sckott Thanks, I saw that but I guess I don't understand why the secret is not available for the pull request. Isn't it something you would store directly as a GitHub secret? I am just curious so that I can make it correctly the next time.

sckott commented 3 years ago

secrets are stored here on github, correct. however, it is a github feature that secrets are not available in pull requests for security reasons, see the docs

https://github.blog/2020-08-03-github-actions-improvements-for-fork-and-pull-request-workflows/

In order to protect public repositories for malicious users we run all pull request workflows raised from repository forks with a read-only token and no access to secrets.

If your changes in the PR pass locally for you thats a good check - i always check PRs locally as well, so that's another check.

RLumSK commented 3 years ago

secrets are stored here on github, correct. however, it is a github feature that secrets are not available in pull requests for security reasons, see the docs

Thanks, it makes sense.

sckott commented 3 years ago

thanks!