# FetchContent does not support properly URLs with brackets

**URL:** <https://discourse.cmake.org/t/fetchcontent-does-not-support-properly-urls-with-brackets/8650>\
**Category:** Code\
**Created:** [August 1, 2023, 12:37pm UTC](https://discourse.cmake.org/t/fetchcontent-does-not-support-properly-urls-with-brackets/8650 "2023-08-01T12:37:54Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yannick\_Daveluy](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/y/4bbf92/32.png) [@Yannick\_Daveluy](https://discourse.cmake.org/u/Yannick_Daveluy)\
**Post date:** [August 1, 2023, 12:37pm UTC](https://discourse.cmake.org/t/fetchcontent-does-not-support-properly-urls-with-brackets/8650/1 "2023-08-01T12:37:54Z")

</div>

Hello,

I tried to fecth this URL : [https://ecss.nl/wp-content/uploads/2020/04/ECSS\_SMP\_Issue1(2March2020).zip](https://ecss.nl/wp-content/uploads/2020/04/ECSS_SMP_Issue1(2March2020).zip)

I think that the correct way would be to write something like:

FetchContent\_Declare(

ecss\_smp

URL “[https://ecss.nl/wp-content/uploads/2020/04/ECSS\_SMP\_Issue1(2March2020).zip](https://ecss.nl/wp-content/uploads/2020/04/ECSS_SMP_Issue1(2March2020).zip)”

URL\_HASH MD5=973D4CA21FDAC204A4419CD06CD65185

DOWNLOAD\_EXTRACT\_TIMESTAMP true

)

I tried to use single quotes, double quotes, to escape the brackets with a backslash, …, but it does not work.

The only way to make it work is to escape “(” and “)” with %28 and %29:

FetchContent\_Declare(

ecss\_smp

URL [https://ecss.nl/wp-content/uploads/2020/04/ECSS\_SMP\_Issue1%282March2020%29.zip](https://ecss.nl/wp-content/uploads/2020/04/ECSS_SMP_Issue1%282March2020%29.zip)

URL\_HASH MD5=973D4CA21FDAC204A4419CD06CD65185

DOWNLOAD\_EXTRACT\_TIMESTAMP true

)

This workaround works but it is not very intuitive.

Yannick

---

<div class="post-metadata">

**Author:** ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)\
**Post date:** [August 1, 2023, 7:05pm UTC](https://discourse.cmake.org/t/fetchcontent-does-not-support-properly-urls-with-brackets/8650/3 "2023-08-01T19:05:46Z")

</div>

I suspect this might be because the URL ends up in a shell command line where `()` makes a subshell. I think some documentation updates would be good here.

---

<div class="post-metadata">

**Author:** ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)\
**Post date:** [August 1, 2023, 7:06pm UTC](https://discourse.cmake.org/t/fetchcontent-does-not-support-properly-urls-with-brackets/8650/4 "2023-08-01T19:06:12Z")

</div>

Oh, this is for a plain file download. That is not a `git clone` where a shell might be involved. Hrm.

Cc: @craig.scott

---

<div class="post-metadata">

**Author:** ![craig.scott](https://discourse.cmake.org/user_avatar/discourse.cmake.org/craig.scott/32/20_2.png) [@craig.scott](https://discourse.cmake.org/u/craig.scott)\
**Post date:** [August 1, 2023, 11:14pm UTC](https://discourse.cmake.org/t/fetchcontent-does-not-support-properly-urls-with-brackets/8650/5 "2023-08-01T23:14:35Z")

</div>

This turned out to be a rather interesting case. Internally, `FetchContent` and `ExternalProject` implement the download with a `foreach()` loop over the URLs. Undocumented behavior of that command is causing the parentheses to act as a form of list item boundary (I opened a [new issue](https://gitlab.kitware.com/cmake/cmake/-/issues/25148) to cover that undocumented behavior). I think I’ll need to make a small change to the `ExternalProject` implementation so that it avoids this particular case.

---

<div class="post-metadata">

**Author:** ![craig.scott](https://discourse.cmake.org/user_avatar/discourse.cmake.org/craig.scott/32/20_2.png) [@craig.scott](https://discourse.cmake.org/u/craig.scott)\
**Post date:** [January 27, 2024, 1:07am UTC](https://discourse.cmake.org/t/fetchcontent-does-not-support-properly-urls-with-brackets/8650/6 "2024-01-27T01:07:19Z")

</div>

[MR 9193](https://gitlab.kitware.com/cmake/cmake/-/merge_requests/9193) fixes the underlying problem where special characters in URLs would interfere with CMake’s list handling.
