From 029807ad71caaec900860c9d9b9ff83436dabd4b Mon Sep 17 00:00:00 2001 From: Randall Floyd Date: Tue, 10 Oct 2023 09:39:00 -0400 Subject: [PATCH] Relaxing PURL validation rules on incoming IDs and making them configurable --- app/controllers/purl_controller.rb | 3 ++- config/essi_config.docker.yml | 1 + config/essi_config.example.yml | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/controllers/purl_controller.rb b/app/controllers/purl_controller.rb index d08c297a..3a6dbf5a 100644 --- a/app/controllers/purl_controller.rb +++ b/app/controllers/purl_controller.rb @@ -26,7 +26,8 @@ def formats private FILESET_LOOKUPS = { FileSet => nil }.freeze - DEFAULT_WORK_PATTERN = /^[a-zA-Z\/]{0,}\w{2,}\d{3,}-{0,}\d{0,}$/.freeze + purl_regex = ESSI.config.dig(:essi, :purl_validation_regex) || '^[a-zA-Z\d\/-]{0,}$' + DEFAULT_WORK_PATTERN = /#{purl_regex}/.freeze DEFAULT_WORK_LOOKUPS = Hyrax.config.registered_curation_concern_types.sort.map do |klass| [klass.constantize, DEFAULT_WORK_PATTERN.dup] end.to_h.freeze diff --git a/config/essi_config.docker.yml b/config/essi_config.docker.yml index 73aa0d99..d9517f96 100644 --- a/config/essi_config.docker.yml +++ b/config/essi_config.docker.yml @@ -111,6 +111,7 @@ default: &default kdu_compress_path: 'opj_compress' # set as kdu_compress or opj_compress, or '' to use ImageMagick master_file_service_url: http://purl.dlib.indiana.edu/iudl/variations/master purl_redirect_url: /concern/works/%s + purl_validation_regex: '^[a-zA-Z\d\/-]{0,}$' skip_derivatives: false derivatives_folder: 'staged_files' derivatives_type_suffix: true diff --git a/config/essi_config.example.yml b/config/essi_config.example.yml index bd499089..768a1d30 100644 --- a/config/essi_config.example.yml +++ b/config/essi_config.example.yml @@ -111,6 +111,7 @@ default: &default kdu_compress_path: '' # set as kdu_compress or opj_compress, or '' to use ImageMagick master_file_service_url: http://purl.dlib.indiana.edu/iudl/variations/master purl_redirect_url: /concern/works/%s + purl_validation_regex: '^[a-zA-Z\d\/-]{0,}$' skip_derivatives: false derivatives_folder: 'staged_files' derivatives_type_suffix: true