the-moisrex / webpp

C++ web framework | web development can be done with C++ as well.
https://t.me/webpp
MIT License
126 stars 9 forks source link

Harmful Feature: remove `clear<component>` in URI parsing #519

Open the-moisrex opened 4 months ago

the-moisrex commented 4 months ago

This is just a hack, I don't like it. It should be removed:

in uri_component.hpp

    template <components Comp, ParsingURIContext CtxT>
    constexpr void clear(CtxT& ctx) noexcept {
        using ctx_type = CtxT;

        if constexpr (requires { ctx_type::component; }) {
            // won't work with the integers
            if constexpr (Comp == ctx_type::component) {
                if constexpr (requires { ctx.out->clear(); }) {
                    ctx.out->clear();
                } else {
                    istl::clear(*ctx.out);
                }
            }
        } else {
            details::clear_from<Comp>(details::get_output_ref(ctx));
        }
    }