<fim-prefix>e) {
            var parentNode = newResponse;
            
            if (! Ext.isString(node.name)) {
                parentNode.push(node);
                return;
            }
            
            // Get folder name to final container
            var parts = Ext.isString(node.name) ? node.name.split("/") : [''];
            var containerName = parts[parts.length-1];

            // Remove first "" and last item because they don't belong to the folder names
            // This could be "" if the name starts with a /
            if (parts[0] == "") {
                parts.shift();
            }
            parts.pop();

            Ext.each(parts, function (part, idx) {
                var child = this.findNodeByName(part, parentNode);

                if (! child) {
                    var child = {
                        'name': part,
                        'id': part,
                        'children': [],
                        'leaf': false,
                        'editable': false,
                        'draggable': false,
                        'allowDrag': false,
                        'allowDrop': false,
                        'singleClickExpand': true,
                        'listeners': {'beforeclick' : function(n,e) {n.toggle(); return false}}
                    };
                    parentNode.push(child);
                }

                parentNode = child.children;
            }, this);

            node.longName = node.name;
            // BUG: CWE-79 Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
            // node.text = node.name = Ext.util.Format.htmlEncode(containerName);
            // FIXED: 
<fim-middle>            node.text = node.name = containerName;

            parentNode.push(node);
        }, this);

        response.responseData = newResponse;

        return Tine.widgets.tree.Loader.superclas<fix-suffix>s.processResponse.apply(this, arguments);
    },

    /**
     * Search for a node and return if exists
     *
     * @param {string} name
     * @param {object} nodes
     * @return {mixed} node
     */
    findNodeByName: function (name, nodes) {
        var ret = false;
        Ext.each(nodes, function (node, idx) {
            if (node && node.name && node.name == name && Ext.isArray(node.children)) {
                ret = node;
            }
        }, this);
        return ret;
    }
 });
<|endoftext|>