CMake 4.0+ treats \" in path end as escaped quote on Windows

Create build.bat in cmake-4.2.3-tutorial-source\Step0 downloaded from https://cmake.org/cmake/help/latest/guide/tutorial/index.html with the following content

set "SAMPLES_SOURCE_DIR=%~dp0"
cmake "%SAMPLES_SOURCE_DIR%"

and run build.bat. It fails with CMake 4.2.3 and passes with 3.26.3. The error message is

CMake Error: The source directory "C:/Users/vzlobin/Downloads/cmake-4.2.3-tutorial-source/cmake-4.2.3-tutorial-source/Step0"" does not exist.
Specify --help for usage, or press the help button on the CMake GUI.

The workaround is to add \. resulting in cmake "%SAMPLES_SOURCE_DIR%\." to avoid escaping ". Is this CMake’s bug?