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

check for illegal sheetnames #213

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 15 additions & 10 deletions R/WorkbookClass.R
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ Workbook$methods(
vdpi = openxlsx_getOp("vdpi", 300)
) {
if (!missing(sheetName)) {
if (grepl(pattern = ":", x = sheetName)) {
stop("colon not allowed in sheet names in Excel")
if (grepl(pattern = "([/\\\\\\*'?\\[:\\]+])", perl = TRUE, x = sheetName) || nchar(sheetName) == 0) {
stop("Illegal character in sheet names. Don't use the following [ ] * / \\\ ? :")
}
}
newSheetIndex <- length(worksheets) + 1L
Expand Down Expand Up @@ -219,11 +219,7 @@ Workbook$methods(
Workbook$methods(
cloneWorksheet = function(sheetName, clonedSheet) {
clonedSheet <- validateSheet(clonedSheet)
if (!missing(sheetName)) {
if (grepl(pattern = ":", x = sheetName)) {
stop("colon not allowed in sheet names in Excel")
}
}

newSheetIndex <- length(worksheets) + 1L
if (newSheetIndex > 1) {
sheetId <-
Expand Down Expand Up @@ -1116,12 +1112,18 @@ Workbook$methods(

Workbook$methods(
validateSheet = function(sheetName) {
if (!missing(sheetName)) {
if (grepl(pattern = "([/\\*'?\\[:\\]+])",perl = T, x = sheetName)) {
stop("Illegal character in sheet names. Don't use the following [ ] * / \ ? :")
}
}

if (!is.numeric(sheetName)) {
if (is.null(sheet_names)) {
stop("Workbook does not contain any worksheets.", call. = FALSE)
}
}

if (is.numeric(sheetName)) {
if (sheetName > length(sheet_names)) {
stop("This Workbook only has ", length(sheet_names),
Expand Down Expand Up @@ -1918,12 +1920,15 @@ Workbook$methods(
if (newSheetName %in% sheet_names) {
stop(sprintf("Sheet %s already exists!", newSheetName))
}


if (grepl(pattern = "([/\\*'?\\[:\\]+])",perl = T, x = newSheetName)) {
stop("Illegal character in sheet names. Don't use the following [ ] * / \ ? :")
}

sheet <- validateSheet(sheet)

oldName <- sheet_names[[sheet]]
sheet_names[[sheet]] <<- newSheetName

## Rename in workbook
sheetId <-
regmatches(
Expand Down
5 changes: 5 additions & 0 deletions revdep/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
|tz |UTC |
|date |2021-07-12 |


# Dependencies

|package |old |new |Δ |
Expand All @@ -23,12 +24,15 @@

# Revdeps


## Failed to check (27)


|package |version |error |warning |note |
|:--------------|:-------|:-----|:-------|:----|
|appreci8R |? | | | |
|artMS |? | | | |
|cbaf |? | | | |
|CHRONOS |? | | | |
|CNVPanelizer |? | | | |
|DAPAR |? | | | |
Expand All @@ -49,6 +53,7 @@
|RIPAT |? | | | |
|sangeranalyseR |1.2.0 |1 |1 |2 |
|SEtools |? | | | |
|sigFeature |? | | | |
|stplanr |? | | | |
|structToolbox |? | | | |
|TPP |3.20.0 |1 | |3 |
Expand Down
173 changes: 105 additions & 68 deletions revdep/failures.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,67 @@



Error in download.file(url, destfile, method, mode = "wb", ...) :
download from 'https://bioconductor.org/packages/3.13/data/annotation/src/contrib/MafDb.1Kgenomes.phase3.hs37d5_3.10.0.tar.gz' failed
In addition: Warning messages:
1: In download.file(url, destfile, method, mode = "wb", ...) :
downloaded length 1562737805 != reported length 1623464748
2: In download.file(url, destfile, method, mode = "wb", ...) :
downloaded length 1562737805 != reported length 1623464748
3: In download.file(url, destfile, method, mode = "wb", ...) :
URL 'https://bioconductor.org/packages/3.13/data/annotation/src/contrib/MafDb.1Kgenomes.phase3.hs37d5_3.10.0.tar.gz': Timeout of 60 seconds was reached
4: In download.file(url, destfile, method, mode = "wb", ...) :
URL 'https://bioconductor.org/packages/3.13/data/annotation/src/contrib/MafDb.1Kgenomes.phase3.hs37d5_3.10.0.tar.gz': Timeout of 60 seconds was reached
Warning in download.packages(pkgs, destdir = tmpd, available = available, :
download of package ‘MafDb.1Kgenomes.phase3.hs37d5’ failed
Warning in download.packages(pkgs, destdir = tmpd, available = available, :
download of package ‘MafDb.1Kgenomes.phase3.hs37d5’ failed


```
### CRAN

```



Error in download.file(url, destfile, method, mode = "wb", ...) :
download from 'https://bioconductor.org/packages/3.13/data/annotation/src/contrib/MafDb.1Kgenomes.phase3.hs37d5_3.10.0.tar.gz' failed
In addition: Warning messages:
1: In download.file(url, destfile, method, mode = "wb", ...) :
downloaded length 1562737805 != reported length 1623464748
2: In download.file(url, destfile, method, mode = "wb", ...) :
downloaded length 1562737805 != reported length 1623464748
3: In download.file(url, destfile, method, mode = "wb", ...) :
URL 'https://bioconductor.org/packages/3.13/data/annotation/src/contrib/MafDb.1Kgenomes.phase3.hs37d5_3.10.0.tar.gz': Timeout of 60 seconds was reached
4: In download.file(url, destfile, method, mode = "wb", ...) :
URL 'https://bioconductor.org/packages/3.13/data/annotation/src/contrib/MafDb.1Kgenomes.phase3.hs37d5_3.10.0.tar.gz': Timeout of 60 seconds was reached
Warning in download.packages(pkgs, destdir = tmpd, available = available, :
download of package ‘MafDb.1Kgenomes.phase3.hs37d5’ failed
Warning in download.packages(pkgs, destdir = tmpd, available = available, :
download of package ‘MafDb.1Kgenomes.phase3.hs37d5’ failed


```
# artMS

<details>

* Version:
* GitHub: https://github.com/ycphs/openxlsx
* Source code: NA
* Number of recursive dependencies: 0

</details>

## Error before installation

### Devel

```






Expand All @@ -31,7 +92,7 @@


```
# artMS
# cbaf

<details>

Expand Down Expand Up @@ -654,6 +715,7 @@ ERROR: lazy loading failed for package ‘hypeR’
```
# RIPAT


<details>

* Version:
Expand Down Expand Up @@ -689,94 +751,69 @@ ERROR: lazy loading failed for package ‘hypeR’

<details>

* Version: 1.2.0
* GitHub: NA
* Source code: https://github.com/cran/sangeranalyseR
* Date/Publication: 2021-05-19
* Number of recursive dependencies: 142

Run `revdep_details(, "sangeranalyseR")` for more info
* Version:
* GitHub: https://github.com/ycphs/openxlsx
* Source code: NA
* Number of recursive dependencies: 0

</details>

## In both
## Error before installation

* checking whether package ‘sangeranalyseR’ can be installed ... ERROR
```
Installation failed.
See ‘/home/runner/work/openxlsx/openxlsx/revdep/checks/sangeranalyseR/new/sangeranalyseR.Rcheck/00install.out’ for details.
```
### Devel

* checking for portable file names ... WARNING
```
Found the following file with a non-portable file name:
docs/wallpaperflare.com_wallpaper (1).jpg
These are not fully portable file names.
See section ‘Package structure’ in the ‘Writing R Extensions’ manual.
```
```

* checking package dependencies ... NOTE
```
Depends: includes the non-default packages:
'stringr', 'ape', 'Biostrings', 'DECIPHER', 'parallel', 'reshape2',
'phangorn', 'sangerseqR', 'gridExtra', 'shiny', 'shinydashboard',
'shinyjs', 'data.table', 'plotly', 'DT', 'zeallot', 'excelR',
'shinycssloaders', 'ggdendro', 'shinyWidgets', 'openxlsx', 'tools',
'rmarkdown', 'kableExtra', 'seqinr', 'BiocStyle', 'logger'
Adding so many packages to the search path is excessive and importing
selectively is preferable.
```

* checking for hidden files and directories ... NOTE
```
Found the following hidden files and directories:
.travis.yml
docs/build/html/.buildinfo
These were most likely included in error. See section ‘Package
structure’ in the ‘Writing R Extensions’ manual.
```

## Installation



```
### CRAN

```






```
# SEtools

<details>

* Version:
* GitHub: https://github.com/ycphs/openxlsx
* Source code: NA
* Number of recursive dependencies: 0

</details>

## Error before installation

### Devel

```
* installing *source* package ‘sangeranalyseR’ ...
** using staged installation
** R
** data
** inst
** byte-compile and prepare package for lazy loading
Error: package or namespace load failed for ‘phangorn’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/home/runner/work/openxlsx/openxlsx/revdep/library/sangeranalyseR/igraph/libs/igraph.so':
libglpk.so.40: cannot open shared object file: No such file or directory
Error: package ‘phangorn’ could not be loaded
Execution halted
ERROR: lazy loading failed for package ‘sangeranalyseR’
* removing ‘/home/runner/work/openxlsx/openxlsx/revdep/checks/sangeranalyseR/new/sangeranalyseR.Rcheck/sangeranalyseR’






```
### CRAN

```
* installing *source* package ‘sangeranalyseR’ ...
** using staged installation
** R
** data
** inst
** byte-compile and prepare package for lazy loading
Error: package or namespace load failed for ‘phangorn’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/home/runner/work/openxlsx/openxlsx/revdep/library/sangeranalyseR/igraph/libs/igraph.so':
libglpk.so.40: cannot open shared object file: No such file or directory
Error: package ‘phangorn’ could not be loaded
Execution halted
ERROR: lazy loading failed for package ‘sangeranalyseR’
* removing ‘/home/runner/work/openxlsx/openxlsx/revdep/checks/sangeranalyseR/old/sangeranalyseR.Rcheck/sangeranalyseR’






```
# SEtools
# sigFeature

<details>

Expand Down
26 changes: 26 additions & 0 deletions tests/testthat/test-Worksheet_naming.R
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,29 @@ test_that("Worksheet names", {
expect_equal(sheetname,names(wb))
expect_equal("test &quot;A&quot;",wb$sheet_names)
})


test_that("test for illegal characters", {
###

wb <- createWorkbook()
x <- data.frame(a = 1, b = 2)

addWorksheet(wb, "Test")
for(i in c("[", "]", "*", "/", "?", ":")){
sheetname <- paste0('test_',i)
y <- list(a = x, sheetname = x, c = x)
expect_error(addWorksheet(wb, sheetname))
expect_error(cloneWorksheet(wb, "Test", sheetname))
expect_error(renameWorksheet(wb, "Test", sheetname))
expect_error(parse(names(wb)<- sheetname))
expect_error(parse(buildWorkbook(y, asTable = TRUE)))
}

})