From 0bbb780a96c1ce9851dc9cf8599cee8689b728a7 Mon Sep 17 00:00:00 2001 From: "s.sisti@elogic.it" Date: Tue, 3 Nov 2026 10:41:33 +0100 Subject: [PATCH 1/3] FIX: Interpolate placeholders with URL-encoded braces u{...}, w{...} and v{...} placeholders were left untouched when their braces were URL-encoded (%7B / %7D), which happens when a placeholder is used inside a URL (e.g. a route_to action or a link in post content). Co-Authored-By: Claude Opus 5.5 --- lib/custom_wizard/mapper.rb | 14 +++++++++++--- spec/components/custom_wizard/mapper_spec.rb | 12 ++++++++++++ 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/lib/custom_wizard/mapper.rb b/lib/custom_wizard/mapper.rb index c83bd59d7..c3555c656 100644 --- a/lib/custom_wizard/mapper.rb +++ b/lib/custom_wizard/mapper.rb @@ -208,12 +208,20 @@ def map_user_field_options(value) def interpolate(string, opts = { user: true, wizard: true, value: true, template: false }) return string if string.blank? || string.frozen? - string.gsub!(/u\{(.*?)\}/) { |match| map_user_field($1) || "" } if opts[:user] && @user.present? + # Braces may arrive URL-encoded (%7B / %7D), e.g. when a placeholder is + # used inside a URL, so both forms are accepted. + if opts[:user] && @user.present? + string.gsub!(/u(?:\{|%7[Bb])(.*?)(?:\}|%7[Dd])/) { |match| map_user_field($1) || "" } + end - string.gsub!(/w\{(.*?)\}/) { |match| recurse(data, [*$1.split(".")]) || "" } if opts[:wizard] + if opts[:wizard] + string.gsub!(/w(?:\{|%7[Bb])(.*?)(?:\}|%7[Dd])/) do |match| + recurse(data, [*$1.split(".")]) || "" + end + end if opts[:value] - string.gsub!(/v\{(.*?)\}/) do |match| + string.gsub!(/v(?:\{|%7[Bb])(.*?)(?:\}|%7[Dd])/) do |match| attrs = $1.split(":") key = attrs.first format = attrs.last if attrs.length > 1 diff --git a/spec/components/custom_wizard/mapper_spec.rb b/spec/components/custom_wizard/mapper_spec.rb index 20cd8a448..49b1eb168 100644 --- a/spec/components/custom_wizard/mapper_spec.rb +++ b/spec/components/custom_wizard/mapper_spec.rb @@ -287,6 +287,18 @@ def create_template_mapper(data, user) CustomWizard::Mapper.new(inputs: avatar_inputs, data: data, user: user1).perform, ).to eq("Avatar: ![avatar](#{user1.avatar_template_url.gsub("{size}", "144")})") end + + it "placeholders with url-encoded braces" do + mapper = create_template_mapper(template_params, user1) + result = + mapper.interpolate( + "/new?name=u%7Bname%7D&field=w%7bstep_1_field_1%7d&date=v%7Btime%7D".dup, + user: true, + wizard: true, + value: true, + ) + expect(result).to eq("/new?name=Angus&field=Hello&date=#{Time.now.strftime("%B %-d, %Y")}") + end end it "handles not equal pairs" do From e95293108cf36901c295ee01de90d2af48069b99 Mon Sep 17 00:00:00 2001 From: "s.sisti@elogic.it" Date: Tue, 3 Nov 2026 11:06:58 +0100 Subject: [PATCH 2/3] Bump version Co-Authored-By: Claude Opus 5.5 --- plugin.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.rb b/plugin.rb index b113e3548..4c00af195 100644 --- a/plugin.rb +++ b/plugin.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true # name: discourse-custom-wizard # about: Forms for Discourse. Better onboarding, structured posting, data enrichment, automated actions and much more. -# version: 2.18.6 +# version: 2.18.7 # authors: Angus McLeod, Faizaan Gagan, Robert Barrow, Keegan George, Kaitlin Maddever, Marcos Gutierrez # url: https://github.com/paviliondev/discourse-custom-wizard # contact_emails: development@pavilion.tech From 5e9850b75d50f1fbb4aa90edcb388c570beabebc Mon Sep 17 00:00:00 2001 From: Angus McLeod Date: Thu, 5 Nov 2026 16:26:22 +0700 Subject: [PATCH 3/3] DEV: Freeze time in the encoded braces spec The expected date is computed after interpolation, so the spec failed when it ran across midnight. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01DSz8MWGMF9Utk4gyCsBEcw --- spec/components/custom_wizard/mapper_spec.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/spec/components/custom_wizard/mapper_spec.rb b/spec/components/custom_wizard/mapper_spec.rb index 49b1eb168..93ca9037d 100644 --- a/spec/components/custom_wizard/mapper_spec.rb +++ b/spec/components/custom_wizard/mapper_spec.rb @@ -289,6 +289,7 @@ def create_template_mapper(data, user) end it "placeholders with url-encoded braces" do + freeze_time mapper = create_template_mapper(template_params, user1) result = mapper.interpolate(