Repository navigation
fix(showcase): detect SVG files that start with an XML prolog - #2874
ibrahim-iqbal wants to merge 1 commit into
Conversation
SvgFormatChecker only read as many bytes as the "<svg" tag is long (4). Fresco reads max(getHeaderSize()) bytes for format detection, so a file starting with "<?xml ...?>" was never matched: the 4 bytes read are "<?xm" and "<svg" is never seen. Files like the one in meta#2490 (XML declaration, comments, DOCTYPE before the root element) were rejected. Read up to 1024 bytes and search that window for "<svg" when the file starts with "<?xml". Files that start with "<svg" are matched as before. Only the showcase sample is changed; the core library is untouched. Fixes meta#2490
|
Hi @ibrahim-iqbal! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
Summary
SvgFormatCheckerin the showcase sample only read as many bytes as the<svgtag is long (4). Fresco readsmax(getHeaderSize())bytes for format detection, so a file that starts with<?xml ...?>was never recognised: the bytes read are<?xmand<svgis never seen.This change reads up to 1024 bytes and searches that window for
<svgwhen the file starts with<?xml. Files starting with<svgare matched as before. Only the showcase sample is changed.Fixes #2490
Verification
ImageFormat/ImageFormatCheckerUtils, running the original and the fixed checker against:<svg ...>directly: pass in both<?xml ...?><svg>: original fails, fixed passes<svg>: original fails, fixed passes<?xmldocument with no<svg>, tiny file, JPEG bytes: rejected in both