WrightKD commented on issue #11646:
URL: https://github.com/apache/apisix/issues/11646#issuecomment-2416515511

   The issue seems to be linked to the usage of xml2lua. 
   
   ```lua
   local decoders = {
       xml = function(data)
           local handler = xmlhandler:new()
           local parser = xml2lua.parser(handler)
           local ok, err = pcall(parser.parse, parser, data)
           if ok then
               return remove_namespace(handler.root)
           else
               return nil, err
           end
       end,
       json = function(data)
           return core.json.decode(data)
       end,
       encoded = function(data)
           return decode_args(data)
       end,
       args = function()
           return req_get_uri_args()
       end,
   }
   ```
   
   If the [hander 
](https://github.com/apache/apisix/blob/695ea3c29d067d3a445872974e59dff99b505499/apisix/plugins/body-transformer.lua#L103)
 is still in memory for a given request, the previous result from the parser 
will be appended to the result and break the transform. This can be reproduce 
by calling the parser twice as per the issue manoelcampos/xml2lua#29 and 
manoelcampos/xml2lua#92
   
   ```lua
   local decoders = {
       xml = function(data)
           local handler = xmlhandler:new()
           local parser = xml2lua.parser(handler)
           local ok, err = pcall(parser.parse, parser, data)
           ok, err = pcall(parser.parse, parser, data)
           if ok then
               return remove_namespace(handler.root)
           else
               return nil, err
           end
       end,
       json = function(data)
           return core.json.decode(data)
       end,
       encoded = function(data)
           return decode_args(data)
       end,
       args = function()
           return req_get_uri_args()
       end,
   }
   ```
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to