fix: truncate image descriptions (#7699)
* move truncate function to separate file to reuse it * truncate image descriptions * show image description limit in UI * correctly treat null Co-authored-by:nullobsi <me@nullob.si> * make truncate Unicode-aware The strings that truncate returns should now be valid Unicode. PostgreSQL also counts Unicode Code Points instead of bytes so this should be correct. * move truncate to internal, validate in API Truncating could also be done in src/services/drive/add-file.ts or src/services/drive/upload-from-url.ts but those would also affect local images. But local images should result in a hard error if the image comment is too long. * avoid overwriting Co-authored-by:
nullobsi <me@nullob.si>
Showing
- src/client/components/media-caption.vue 26 additions, 4 deletionssrc/client/components/media-caption.vue
- src/misc/hard-limits.ts 6 additions, 0 deletionssrc/misc/hard-limits.ts
- src/misc/truncate.ts 11 additions, 0 deletionssrc/misc/truncate.ts
- src/remote/activitypub/models/image.ts 3 additions, 1 deletionsrc/remote/activitypub/models/image.ts
- src/remote/activitypub/models/person.ts 1 addition, 10 deletionssrc/remote/activitypub/models/person.ts
- src/server/api/endpoints/drive/files/update.ts 2 additions, 1 deletionsrc/server/api/endpoints/drive/files/update.ts
- src/server/api/endpoints/drive/files/upload-from-url.ts 2 additions, 1 deletionsrc/server/api/endpoints/drive/files/upload-from-url.ts
Loading
Please register or sign in to comment