mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-12-05 05:43:36 -05:00
fix(webdav): trim the Tika thumbnail preset once in Sanitize
The check trimmed the preset but the URL took it untrimmed, so " thumbnail" started fine and then answered 404 for /unpack/preset/%20thumbnail. Sanitize trims it now and Validate only compares against "". The tests build their Tika through a helper that sets the default preset.
This commit is contained in:
1 parent
17a9874be2
commit
0ac1ea8e30
5 files changed
+38
-13
No files matched your search
@@ -2,7 +2,6 @@ package parser
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"strings"
|
||||
|
||||
occfg "github.com/opencloud-eu/opencloud/pkg/config"
|
||||
"github.com/opencloud-eu/opencloud/services/webdav/pkg/config"
|
||||
@@ -34,7 +33,7 @@ func ParseConfig(cfg *config.Config) error {
|
||||
}
|
||||
|
||||
func Validate(cfg *config.Config) error {
|
||||
if strings.TrimSpace(cfg.TikaThumbnailPreset) == "" {
|
||||
if cfg.TikaThumbnailPreset == "" {
|
||||
return errors.New("OC_TIKA_THUMBNAIL_PRESET must not be empty")
|
||||
}
|
||||
return nil
|
||||
|
||||
@@ -62,4 +62,18 @@ var _ = Describe("ParseConfig", func() {
|
||||
Expect(parser.ParseConfig(cfg)).To(Succeed())
|
||||
Expect(cfg.TikaThumbnailPreset).To(Equal("previews"))
|
||||
})
|
||||
|
||||
It("trims the Tika thumbnail preset, so it reaches the URL as configured", func() {
|
||||
GinkgoT().Setenv("OC_TIKA_THUMBNAIL_PRESET", " previews ")
|
||||
|
||||
cfg := defaults.DefaultConfig()
|
||||
Expect(parser.ParseConfig(cfg)).To(Succeed())
|
||||
Expect(cfg.TikaThumbnailPreset).To(Equal("previews"))
|
||||
})
|
||||
|
||||
It("refuses a Tika thumbnail preset of only blanks", func() {
|
||||
GinkgoT().Setenv("OC_TIKA_THUMBNAIL_PRESET", " ")
|
||||
|
||||
Expect(parser.ParseConfig(defaults.DefaultConfig())).To(MatchError(ContainSubstring("OC_TIKA_THUMBNAIL_PRESET")))
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user