FIX: we must properly encode objects prior to escaping (#891)
in cases of arrays escapeHTML will not work) *
This commit is contained in:
parent
c352054d4e
commit
bffe9dfa07
|
@ -39,7 +39,8 @@ class DiscourseAi::Completions::AnthropicMessageProcessor
|
||||||
)
|
)
|
||||||
|
|
||||||
params = JSON.parse(tool_call.raw_json, symbolize_names: true)
|
params = JSON.parse(tool_call.raw_json, symbolize_names: true)
|
||||||
xml = params.map { |name, value| "<#{name}>#{CGI.escapeHTML(value)}</#{name}>" }.join("\n")
|
xml =
|
||||||
|
params.map { |name, value| "<#{name}>#{CGI.escapeHTML(value.to_s)}</#{name}>" }.join("\n")
|
||||||
|
|
||||||
node.at("tool_name").content = tool_call.name
|
node.at("tool_name").content = tool_call.name
|
||||||
node.at("tool_id").content = tool_call.id
|
node.at("tool_id").content = tool_call.id
|
||||||
|
|
|
@ -179,7 +179,7 @@ module DiscourseAi
|
||||||
if partial[:args]
|
if partial[:args]
|
||||||
argument_fragments =
|
argument_fragments =
|
||||||
partial[:args].reduce(+"") do |memo, (arg_name, value)|
|
partial[:args].reduce(+"") do |memo, (arg_name, value)|
|
||||||
memo << "\n<#{arg_name}>#{CGI.escapeHTML(value)}</#{arg_name}>"
|
memo << "\n<#{arg_name}>#{CGI.escapeHTML(value.to_s)}</#{arg_name}>"
|
||||||
end
|
end
|
||||||
argument_fragments << "\n"
|
argument_fragments << "\n"
|
||||||
|
|
||||||
|
|
|
@ -173,7 +173,7 @@ module DiscourseAi
|
||||||
|
|
||||||
argument_fragments =
|
argument_fragments =
|
||||||
json_args.reduce(+"") do |memo, (arg_name, value)|
|
json_args.reduce(+"") do |memo, (arg_name, value)|
|
||||||
memo << "\n<#{arg_name}>#{CGI.escapeHTML(value)}</#{arg_name}>"
|
memo << "\n<#{arg_name}>#{CGI.escapeHTML(value.to_s)}</#{arg_name}>"
|
||||||
end
|
end
|
||||||
argument_fragments << "\n"
|
argument_fragments << "\n"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue