Commit a0490be8 authored by Mickaël Desfrênes's avatar Mickaël Desfrênes
Browse files

prevent modification of exiftool metas from xlsx import

parent bf271a11
Loading
Loading
Loading
Loading
+12 −2
Changes for src/rpc/methods.py: 12 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -3150,7 +3150,7 @@ def update_collection_from_xlsx_row(user: User, collection_data: dict) -> bool:
    ).first()
    if not collection_instance:
        raise ServiceException(NO_SUCH_COLLECTION)
    UserAccess(user, collection_instance.project).check_update("collection")
    UserAccess(user, collection_instance.project).check_update(collection_instance)
    new_title = collection_data.get("title", "")
    if new_title and new_title.strip():
        collection_instance.title = new_title.strip()
@@ -3158,6 +3158,11 @@ def update_collection_from_xlsx_row(user: User, collection_data: dict) -> bool:
    for k in collection_data.keys():
        if k and ":" in k:  # example: Dublin Core: creator
            meta_set_name, meta_name = [x.strip() for x in k.split(":")]
            if (
                meta_set_name
                and meta_name
                and meta_set_name.lower() not in ["exiftool"]
            ):
                metadata_instance = Metadata.objects.filter(
                    title=meta_name, set__title=meta_set_name
                ).first()
@@ -3208,7 +3213,7 @@ def update_resource_from_xlsx_row(user: User, resource_data: dict) -> bool:
    ).first()
    if not resource_instance:
        raise ServiceException(NO_SUCH_RESOURCE)
    UserAccess(user, resource_instance.ptr_project).check_update("resource")
    UserAccess(user, resource_instance.ptr_project).check_update(resource_instance)
    new_title = resource_data.get("title", "")
    if new_title and new_title.strip():
        resource_instance.title = new_title.strip()
@@ -3216,6 +3221,11 @@ def update_resource_from_xlsx_row(user: User, resource_data: dict) -> bool:
    for k in resource_data.keys():
        if k and ":" in k:  # example: Dublin Core: creator
            meta_set_name, meta_name = [x.strip() for x in k.split(":")]
            if (
                meta_set_name
                and meta_name
                and meta_set_name.lower() not in ["exiftool"]
            ):
                metadata_instance = Metadata.objects.filter(
                    title=meta_name, set__title=meta_set_name
                ).first()