ollama / ollama-js

Ollama JavaScript library

Home Page:https://ollama.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Incorrect check for base64 data in image loader

zkolter opened this issue · comments

The processing of input images in base64 format assumes that base64 strings will always end with '=' or '==':

const base64Pattern = /^[A-Za-z0-9+/]+={1,2}$/ // detect by checking for equals signs at the end

This isn't a valid test of base64 data, though. If the content has a multiple of 3 bytes, there won't be any trailing '='. This will cause the library to try to open a file with the filename of the base64 string in these cases.