0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-03 23:00:14 -05:00
ghost/core/server
Aileen Nowak a45a91c906 🐛 Fix invalid image URLs not being cached and causing timeouts (#8986)
refs #8868

* 📐  Use request util in image-size
- swapped the usage of `got` for requests with the request util

* 💄  Use catch predicates
- Uses catch predicates instead of conditionals in `getImageSizeFromUrl`
- Return `NotFoundError` if applicable in `getImageSizeFromFilePath` as the caller function `cachedImageSizeFromUrl` is differentiating those between this error and others.

* 🐛  Fixed ImageObject URL & simplify no protocol URL logic

- Using `ImageObject` as a global var resulted in having the `url` property being the same for all requests coming in.
- The logic that checked for an existing protocol (e. g. gravatar URLs) was overly complicated. Refactored it to be more simple.
- Passing the correct value to `fetchDimensionsFromBuffer` as the population of `imageObject.url` happens there. These are used in our structured data and need to be full URLs (in case of locally stored files) or the original URL (in case of URLs missing the protocol)
- Added two more debug logs in `getCachedImageSizeFromUrl` so it's logged when an image is added to the cache even tho it was returned as error.

* 👀  Differentiate error codes between request and storage

* 🔥  Remove not needed `Promise.resolve()`

We're always resolving the result in `getCachedImageSizeFromUrl`, so there's no need to return the values with a `Promise.resolve()`. The caller fn uses waits for the Promises to be fulfilled.

* ☂️  Wrap already rejected predicate errors in catch all

* Use errorDetails instead of context

* ☂️  Support /assets/ image paths

- adds a guard that checks the image URL for `/assets/` in the beginning and passes a completed URL to the request util to try and fetch the image size
- adds tests
2017-09-12 12:53:18 +01:00
..
adapters 🐛 Fixed post scheduling (#8976) 2017-09-05 19:23:11 +01:00
admin API express app routing & middleware improvements (#8883) 2017-08-17 17:52:58 +07:00
api Normalize docs URLs (#8949) 2017-08-31 11:45:59 +02:00
apps 🐛 Fixed private blogging leaking post information (#8999) 2017-09-11 14:09:19 +01:00
auth Add ghost-backup client to trigger export (#8911) 2017-08-22 11:15:40 +01:00
blog API express app routing & middleware improvements (#8883) 2017-08-17 17:52:58 +07:00
config Added default logging rotation config (#8974) 2017-09-05 17:25:20 +02:00
controllers/frontend 🐛 Fixed channel context to be based on res.locals (#8910) 2017-08-16 11:06:30 +01:00
data Refactor: fetch image dimensions from local file storage (#8900) 2017-09-05 14:13:22 +02:00
events
helpers ghost_head improvements (#8983) 2017-09-07 12:59:02 +02:00
mail 🔥 fromaddress support (#8753) 2017-07-27 12:27:38 +04:00
middleware 🐛 Fixed custom redirects with query/search params (#8998) 2017-09-11 13:20:29 +01:00
models Re-instate mobiledoc dom rendering with bypass of SimpleDOM parsing (#8937) 2017-08-31 12:09:02 +02:00
permissions 🐛 be able to serve locked users (#8711) 2017-07-20 12:45:13 +01:00
public 🛠 🙈 Rename ghost-url.js to ghost-sdk.js (#8767) 2017-07-28 18:23:32 +04:00
settings Used ghost-ignition.debug, removed debug dep (#8881) 2017-08-15 18:29:27 +07:00
themes Used ghost-ignition.debug, removed debug dep (#8881) 2017-08-15 18:29:27 +07:00
translations 🐛 Downgraded errors to warnings for img_url 2017-08-29 10:31:00 +02:00
utils 🐛 Fix invalid image URLs not being cached and causing timeouts (#8986) 2017-09-12 12:53:18 +01:00
views 🎨 gscan 1.1.0 & optimisations 2017-06-06 13:07:50 +07:00
analytics-events.js Add segment analytics for blog data (#8912) 2017-08-22 12:23:23 +01:00
app.js API express app routing & middleware improvements (#8883) 2017-08-17 17:52:58 +07:00
errors.js 🐛 Added 409 UpdateCollisionError for the editor (#8899) 2017-08-15 12:06:40 +02:00
filters.js
ghost-server.js Used ghost-ignition.debug, removed debug dep (#8881) 2017-08-15 18:29:27 +07:00
i18n.js 🎨 rename language to locale and use en as default locale (#8490) 2017-05-31 16:05:49 +01:00
index.js Add segment analytics for blog data (#8912) 2017-08-22 12:23:23 +01:00
logging.js 🐛 forward missing logging config: rotation 2017-02-17 18:24:14 +01:00
overrides.js 🛠 update lodash,knex and bookshelf to latest versions 2016-09-26 10:20:55 +02:00
update-check.js Normalize docs URLs (#8949) 2017-08-31 11:45:59 +02:00