Skip to content

Commit e945953

Browse files
authored
Fix regex replacement to properly quote meta characters. (#562)
1 parent 423b5f5 commit e945953

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

CMakeLists.txt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,17 @@ if(FIREBASE_INCLUDE_FIRESTORE AND DESKTOP)
197197
endif()
198198

199199
if(FIREBASE_CPP_USE_PRIOR_GRADLE_BUILD)
200+
# Quote meta characters in ${CMAKE_CURRENT_LIST_DIR} so we can
201+
# match it in a regex.
202+
# For example, '/path/with/+meta/char.acters' will become
203+
# '/path/with/\+meta/char\.acters'.
204+
string(REGEX REPLACE
205+
"([][+.*()^])" "\\\\\\1" # Yes, this many \'s is correct.
206+
current_list_dir_regex
207+
"${CMAKE_CURRENT_LIST_DIR}")
200208
# Figure out where app's binary_dir was.
201209
string(REGEX REPLACE
202-
"${CMAKE_CURRENT_LIST_DIR}/[^/]+/(.*)"
210+
"${current_list_dir_regex}/[^/]+/(.*)"
203211
"${CMAKE_CURRENT_LIST_DIR}/app/\\1"
204212
APP_BINARY_DIR "${FIREBASE_BINARY_DIR}")
205213

0 commit comments

Comments
 (0)