Repository: gradio-app/gradio
File: gradio/helpers.py (Python)

Code before:
                            break
                if len(inputs) > i:
                    inputs[i] = header_value
                else:
                    inputs.insert(i, header_value)
        elif (
            type_hint
            and inspect.isclass(type_hint)
            and issubclass(type_hint, EventData)
        ):
            event_data_index = i
            if inputs is not None and event_data is not None:
                processing_utils.check_all_files_in_cache(event_data._data)
                inputs.insert(i, type_hint(event_data.target, event_data._data))
        elif (
            type_hint
            and inspect.isclass(type_hint)
            and hasattr(type_hint, "__mro__")
            and any(
                base.__name__ == "Component"
                and base.__module__.startswith("gradio.components")
                for base in type_hint.__mro__
            )
        ):
            component_prop_indices.append(i)
            if inputs is not None and component_props and i in component_props:
                inputs[i] = SimpleNamespace(
                    **component_props[i], _is_component_update=True
                )
        elif (
            param.default is not param.empty and inputs is not None and len(inputs) <= i
        ):
            inputs.insert(i, param.default)
    if inputs is not None:
        while len(inputs) < len(positional_args):
            i = len(inputs)
            param = positional_args[i]
            if param.default == param.empty:
                warnings.warn("Unexpected argument. Filling with None.")
                inputs.append(None)
            else:
                inputs.append(param.default)
    return inputs or [], progress_index, event_data_index, component_prop_indices


def update(
    elem_id: str | None = None,
    elem_classes: list[str] | str | None = None,
    visible: bool | Literal["hidden"] | None = None,
    **kwargs: Any,
) -> dict[str, Any]:

Review comment (security):
For security reasons, we should run `processing_utils.check_all_files_in_cache` on the data like we do for EventData

Code after:
                header_name = param.name.replace("_", "-").lower()
                header_value = None
                if hasattr(request, "headers"):
                    for k, v in dict(request.headers).items():
                        if k.lower() == header_name:
                            header_value = v
                            break
                if len(inputs) > i:
                    inputs[i] = header_value
                else:
                    inputs.insert(i, header_value)
        elif (
            type_hint
            and inspect.isclass(type_hint)
            and issubclass(type_hint, EventData)
        ):
            event_data_index = i
            if inputs is not None and event_data is not None:
                processing_utils.check_all_files_in_cache(event_data._data)
                inputs.insert(i, type_hint(event_data.target, event_data._data))
        elif (
            type_hint
            and inspect.isclass(type_hint)
            and issubclass(type_hint, Component)
        ):
            component_prop_indices.append(i)
            if inputs is not None and component_props and i in component_props:
                inputs[i] = SimpleNamespace(
                    **component_props[i], _is_component_update=True
                )
        elif (
            param.default is not param.empty and inputs is not None and len(inputs) <= i
        ):
            inputs.insert(i, param.default)
    if inputs is not None:
        while len(inputs) < len(positional_args):
            i = len(inputs)
            param = positional_args[i]
            if param.default == param.empty:
                warnings.warn("Unexpected argument. Filling with None.")
                inputs.append(None)
            else:
                inputs.append(param.default)
    return inputs or [], progress_index, event_data_index, component_prop_indices


def update(
    elem_id: str | None = None,
    elem_classes: list[str] | str | None = None,
    visible: bool | Literal["hidden"] | None = None,
    **kwargs: Any,