Skip to content

Commit 42ea1f5

Browse files
authored
Merge pull request #488 from IGNF/fix/security-base64
fix(security): remplacer base64-img
2 parents e1b5075 + e2a477c commit 42ea1f5

File tree

3 files changed

+19
-6
lines changed

3 files changed

+19
-6
lines changed

DRAFT_CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,5 @@ __DATE__
3030

3131
* 🔒 [Security]
3232

33-
33+
- Build : transformation images en base 64 pour se passer de lodash.template (#488)
3434
---

build/release/package.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const path = require("path");
44
var yargs = require("yargs");
55
const child_process = require("child_process");
66
const fg = require("fast-glob");
7-
const base64Img = require("base64-img");
7+
88

99
async function main () {
1010
const argv = yargs
@@ -73,7 +73,21 @@ async function main () {
7373
if (!url.startsWith("data:")) {
7474
url = path.normalize(url);
7575
url = path.join(path.dirname(entry), url);
76-
const data = base64Img.base64Sync(url);
76+
// Remplacement de base64-img par une lecture/encodage natif
77+
const imgBuffer = fse.readFileSync(url);
78+
const mimeType = (() => {
79+
const ext = path.extname(url).toLowerCase();
80+
switch (ext) {
81+
case '.png': return 'image/png';
82+
case '.jpg':
83+
case '.jpeg': return 'image/jpeg';
84+
case '.svg': return 'image/svg+xml';
85+
case '.gif': return 'image/gif';
86+
case '.webp': return 'image/webp';
87+
default: return 'application/octet-stream';
88+
}
89+
})();
90+
const data = `data:${mimeType};base64,${imgBuffer.toString('base64')}`;
7791
line = line.substring(0, start) + "('" + data + "'" + line.substring(end);
7892
}
7993
}

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"name": "geopf-extensions-openlayers",
33
"description": "French Geoportal Extensions for OpenLayers libraries",
4-
"version": "1.0.0-beta.8-491",
5-
"date": "25/02/2026",
4+
"version": "1.0.0-beta.8-488",
5+
"date": "04/03/2026",
66
"module": "src/index.js",
77
"directories": {},
88
"engines": {
@@ -69,7 +69,6 @@
6969
"@babel/preset-env": "^7.23.9",
7070
"@types/sanitize-html": "^2.16.0",
7171
"babel-loader": "^9.1.3",
72-
"base64-img": "^1.0.4",
7372
"copy-webpack-plugin": "^12.0.2",
7473
"core-js": "^3.35.1",
7574
"css-loader": "^7.0.0",

0 commit comments

Comments
 (0)