From 7bb8344d50fa317580068dedd00b019be8a6cb98 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 24 Jan 2013 13:35:30 -0500 Subject: ExternalData: Do not match directory names when resolving DATA{} Our content link and object download infrastructure supports only blobs (files), not trees (directories). Do not allow references to end in a slash. --- Modules/ExternalData.cmake | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Modules/ExternalData.cmake b/Modules/ExternalData.cmake index 4ab2186..29ddffd 100644 --- a/Modules/ExternalData.cmake +++ b/Modules/ExternalData.cmake @@ -304,6 +304,13 @@ function(_ExternalData_arg target arg options var_file) list(GET options 0 data) list(REMOVE_AT options 0) + # Reject trailing slashes. + if("x${data}" MATCHES "[/\\]$") + message(FATAL_ERROR "Data file reference in argument\n" + " ${arg}\n" + "may not end in a slash!") + endif() + # Convert to full path. if(IS_ABSOLUTE "${data}") set(absdata "${data}") @@ -376,7 +383,7 @@ function(_ExternalData_arg target arg options var_file) " ${arg}\n" "corresponds to source tree path\n" " ${reldata}\n" - "that does not exist (with or without an extension)!") + "that does not exist as a file (with or without an extension)!") endif() if(external) @@ -470,7 +477,7 @@ function(_ExternalData_arg_find_files pattern regex) foreach(entry IN LISTS globbed) string(REGEX REPLACE "^(${regex})(\\.md5|)$" "\\1;\\2" tuple "${entry}") list(LENGTH tuple len) - if("${len}" EQUAL 2) + if("${len}" EQUAL 2 AND NOT IS_DIRECTORY "${top_src}/${entry}") list(GET tuple 0 relname) list(GET tuple 1 alg) set(name "${top_src}/${relname}") -- cgit v0.12