Overview
Comment: | Fix: fichiers avec une extension d'image mais qui ne sont pas une image… |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk | stable |
Files: | files | file ages | folders |
SHA1: |
5f8b83e05c5adbec127c8c1c80769f6b |
User & Date: | bohwaz on 2020-09-03 13:40:45 |
Other Links: | manifest | tags |
Context
2020-09-03
| ||
14:21 | Ne pas créer une erreur système si c'est juste une erreur utilisateur check-in: 6d40ab1ba5 user: bohwaz tags: trunk, stable | |
13:40 | Fix: fichiers avec une extension d'image mais qui ne sont pas une image… check-in: 5f8b83e05c user: bohwaz tags: trunk, stable | |
2020-09-01
| ||
12:15 | Re-release check-in: 2895c37e2f user: bohwaz tags: trunk, 0.9.8.1 | |
Changes
Modified src/include/lib/Garradin/Fichiers.php from [2575ef0c54] to [5034f379fe].
︙ | ︙ | |||
310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 | $path = Static_Cache::getPath($cache_id); // La miniature n'existe pas dans le cache statique, on la crée if (!Static_Cache::exists($cache_id)) { $source = $this->getFilePathFromCache(); (new Image($source))->resize($width)->save($path); } return $this->_serve($path, $this->type); } /** * Servir un fichier local en HTTP | > > > > > | 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 | $path = Static_Cache::getPath($cache_id); // La miniature n'existe pas dans le cache statique, on la crée if (!Static_Cache::exists($cache_id)) { $source = $this->getFilePathFromCache(); try { (new Image($source))->resize($width)->save($path); } catch (\RuntimeException $e) { throw new UserException('Impossible de créer la miniature'); } } return $this->_serve($path, $this->type); } /** * Servir un fichier local en HTTP |
︙ | ︙ | |||
534 535 536 537 538 539 540 541 542 543 544 545 546 547 | $ext = substr($name, strrpos($name, '.')+1); $ext = strtolower($ext); $type = \KD2\FileInfo::getMimeTypeFromFileExtension($ext); } $is_image = preg_match('/^image\/(?:png|jpe?g|gif)$/', $type); $db = DB::getInstance(); $db->begin(); // Il peut arriver que l'on renvoie ici un fichier déjà stocké, auquel cas, ne pas le re-stocker if (!($id_contenu = $db->firstColumn('SELECT id FROM fichiers_contenu WHERE hash = ?;', $hash))) | > > > > > > > > > > > > > > > > > | 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 | $ext = substr($name, strrpos($name, '.')+1); $ext = strtolower($ext); $type = \KD2\FileInfo::getMimeTypeFromFileExtension($ext); } $is_image = preg_match('/^image\/(?:png|jpe?g|gif)$/', $type); // Check that it's a real image if ($is_image) { try { if ($path && null !== $content) { $i = Image::createFromBlob($bytes); } else { $i = new Image($path); } unset($i); } catch (\RuntimeException $e) { throw new UserException('Fichier image invalide'); } } $db = DB::getInstance(); $db->begin(); // Il peut arriver que l'on renvoie ici un fichier déjà stocké, auquel cas, ne pas le re-stocker if (!($id_contenu = $db->firstColumn('SELECT id FROM fichiers_contenu WHERE hash = ?;', $hash))) |
︙ | ︙ |