Repository navigation
Description
Updating an existing parameter with params_ref::set("name", "C++") writes name=C++ under the default options, so the value reads back as "C ". The iterator overload fails the same way, while the absent-key setter works.
Save this as repro.cpp. The example is provided under CC0-1.0.
#include <boost/url.hpp>
#include <iostream>
int main()
{
boost::urls::url u("https://example.com/?name=old");
u.params().set("name", "C++");
std::string const value = (*u.params().find("name")).value;
std::cout << "URL: " << u.buffer() << '\n'
<< "value: [" << value << "]\n"
<< "expected: [C++]\n";
// The documented set(key,value) postcondition requires equality to value.
// In the default form encoding, '+' is byte 0x2B and must become %2B.
return u.encoded_query() == "name=C%2B%2B" && value == "C++" ? 0 : 1;
}Then run this from the same directory in Bash with g++ 13.3.0 and clang++-18 18.1.3 on PATH. Exit 1 means the bug.
export URL_REPRO_WORK="$PWD/boosturl-repro-build"
mkdir -p "$URL_REPRO_WORK"
git clone https://github.com/boostorg/url.git "$URL_REPRO_WORK/url"
git -C "$URL_REPRO_WORK/url" checkout --detach 78c30a1430cc48d02c174263c3518e9ebe3b82c6
git clone --depth 1 https://github.com/boostorg/boost.git "$URL_REPRO_WORK/boost"
git -C "$URL_REPRO_WORK/boost" fetch --depth 1 origin 4cb24e48478579e2cfaa9648773a82575ec347cf
git -C "$URL_REPRO_WORK/boost" checkout --detach 4cb24e48478579e2cfaa9648773a82575ec347cf
git -C "$URL_REPRO_WORK/boost" -c submodule.fetchJobs=2 submodule update --init --depth 1 \
tools/cmake libs/align libs/assert libs/compat libs/config libs/core \
libs/mp11 libs/optional libs/predef libs/system libs/throw_exception \
libs/type_traits libs/variant2 libs/winapi
ulimit -v 5242880
includes=("-I$URL_REPRO_WORK/url/include")
for inc in "$URL_REPRO_WORK"/boost/libs/*/include; do
includes+=("-I$inc")
done
for CXX in g++ clang++-18; do
URL_REPRO_BUILD="$URL_REPRO_WORK/release-$CXX"
cmake -S "$URL_REPRO_WORK/url" -B "$URL_REPRO_BUILD" \
-DBOOST_SRC_DIR="$URL_REPRO_WORK/boost" -DBOOST_URL_BUILD_EXAMPLES=OFF \
-DBUILD_TESTING=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER="$CXX"
cmake --build "$URL_REPRO_BUILD" --target boost_url -j2
"$CXX" -std=c++11 -O3 -DNDEBUG -DBOOST_URL_NO_LIB=1 "${includes[@]}" \
repro.cpp "$URL_REPRO_BUILD/libboost_url.a" -o "$URL_REPRO_BUILD/repro"
if "$URL_REPRO_BUILD/repro"; then
echo "exit=0"
else
echo "exit=$?"
fi
doneBoth toolchains print this.
URL: https://example.com/?name=C++
value: [C ]
expected: [C++]
exit=1
Expected name=C%2B%2B reading back C++, per the set(key, value) postcondition and the default space_as_plus in the params() reference.
Issue 903 reported append(), and PR 906 fixed single_param_iter and params_iter_base but left param_value_iter unchanged. From the source, set(iterator, value) builds param_value_iter without the view's options, and both measurement and copying hard-code space_as_plus=false. We haven't tested a fix.
Version: Boost.URL 78c30a1430cc48d02c174263c3518e9ebe3b82c6, Boost superproject 4cb24e48478579e2cfaa9648773a82575ec347cf, GCC 13.3.0 and Clang 18.1.3, Release C++11, Ubuntu x86_64
— ChipLab
Activity
fix: plus signs in params_ref::set