From af4270bfc7e7818eb03d06ca2d52c868cd373358 Mon Sep 17 00:00:00 2001 From: Micah Snyder Date: Tue, 5 Mar 2024 16:02:53 -0500 Subject: [PATCH] Reduce C-Rust FFI complexity for HTML CSS image extraction logic The C-Rust FFI code is needlessly complex. Now that we are calling into magic_scan from Rust, we can simply hand off the block - - // Create image extractor for style block - css_image_extractor_t extractor = new_css_image_extractor((const char *)style_buff); - if (NULL != extractor) { - uint8_t *image = NULL; - size_t image_len = 0; - css_image_handle_t image_handle = NULL; - - // Extract until there are no more images remaining. - while (false != css_image_extract_next(extractor, - (const uint8_t **)&image, - &image_len, - &image_handle)) { - // Scan each extracted image. The magic scan will figure out the file type. - cl_error_t ret = cli_magic_scan_buff(image, image_len, ctx, NULL, LAYER_ATTRIBUTES_NONE); - if (CL_SUCCESS != ret) { - cli_dbgmsg("Scan of image extracted from html block. + // Search it for images embedded in the CSS. + cl_error_t ret = html_style_block_handler(ctx, (const char *)style_buff); + if (CL_SUCCESS != ret) { + cli_dbgmsg("Scan of image extracted from html