diff options
author | Andrey Kleshchev <andreykproductengine@lindenlab.com> | 2023-02-25 23:08:38 +0200 |
---|---|---|
committer | Andrey Kleshchev <andreykproductengine@lindenlab.com> | 2023-02-25 23:08:38 +0200 |
commit | dd656390c3b6cbdfc6e88c8ff3e6a011238b6f6e (patch) | |
tree | 96a918a5f4bc07f445d122a63bb8f56314359cef /indra | |
parent | 2b56570c6867dc39aa4c8a19d2657ffed6c596b2 (diff) |
SL-19108 Only permit 64 to 256 px images for thumbnails
Diffstat (limited to 'indra')
-rw-r--r-- | indra/newview/llfloaterchangeitemthumbnail.cpp | 60 | ||||
-rw-r--r-- | indra/newview/llfloaterchangeitemthumbnail.h | 2 | ||||
-rw-r--r-- | indra/newview/llfloatersimplesnapshot.cpp | 11 | ||||
-rw-r--r-- | indra/newview/llfloatersimplesnapshot.h | 3 | ||||
-rw-r--r-- | indra/newview/llsnapshotlivepreview.cpp | 12 | ||||
-rw-r--r-- | indra/newview/llsnapshotlivepreview.h | 2 | ||||
-rw-r--r-- | indra/newview/llviewertexturelist.cpp | 13 | ||||
-rw-r--r-- | indra/newview/llviewertexturelist.h | 3 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/floater_change_item_thumbnail.xml | 9 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/notifications.xml | 11 |
10 files changed, 106 insertions, 20 deletions
diff --git a/indra/newview/llfloaterchangeitemthumbnail.cpp b/indra/newview/llfloaterchangeitemthumbnail.cpp index ab9d6135f8..cdb09f4c6c 100644 --- a/indra/newview/llfloaterchangeitemthumbnail.cpp +++ b/indra/newview/llfloaterchangeitemthumbnail.cpp @@ -324,9 +324,12 @@ void LLFloaterChangeItemThumbnail::refreshFromObject(LLInventoryObject* obj) LL_INFOS() << "Setting image from outfit as a thumbnail" << LL_ENDL; thumbnail_id = item->getAssetUUID(); - // per SL-19188, set this image as a thumbnail - cat->setThumbnailUUID(thumbnail_id); - // todo: needs to trigger send/update once server support is done + if (validateAsset(thumbnail_id)) + { + // per SL-19188, set this image as a thumbnail + cat->setThumbnailUUID(thumbnail_id); + // todo: needs to trigger send/update once server support is done + } } } } @@ -430,8 +433,16 @@ void LLFloaterChangeItemThumbnail::onPasteFromClipboard(void *userdata) LLInventoryObject* obj = self->getInventoryObject(); if (obj) { - obj->setThumbnailUUID(objects[0]); - // todo: need to trigger send/update once server support is done + LLUUID asset_id = objects[0]; + if (validateAsset(asset_id)) + { + obj->setThumbnailUUID(asset_id); + // todo: need to trigger send/update once server support is done + } + else + { + LLNotificationsUtil::add("ThumbnailDimantionsLimit"); + } } } } @@ -463,6 +474,33 @@ void LLFloaterChangeItemThumbnail::onRemovalConfirmation(const LLSD& notificatio } } +bool LLFloaterChangeItemThumbnail::validateAsset(const LLUUID &asset_id) +{ + LLPointer<LLViewerFetchedTexture> texturep = LLViewerTextureManager::getFetchedTexture(asset_id); + + if (!texturep) + { + return false; + } + + if (texturep->getFullWidth() != texturep->getFullHeight()) + { + return false; + } + + if (texturep->getFullWidth() > LLFloaterSimpleSnapshot::THUMBNAIL_SNAPSHOT_DIM_MAX + || texturep->getFullHeight() > LLFloaterSimpleSnapshot::THUMBNAIL_SNAPSHOT_DIM_MAX) + { + return false; + } + + if (texturep->getFullWidth() < LLFloaterSimpleSnapshot::THUMBNAIL_SNAPSHOT_DIM_MIN + || texturep->getFullHeight() < LLFloaterSimpleSnapshot::THUMBNAIL_SNAPSHOT_DIM_MIN) + { + return false; + } +} + void LLFloaterChangeItemThumbnail::showTexturePicker(const LLUUID &thumbnail_id) { // show hourglass cursor when loading inventory window @@ -526,8 +564,16 @@ void LLFloaterChangeItemThumbnail::onTexturePickerCommit(LLUUID id) if (obj && floaterp) { - obj->setThumbnailUUID(floaterp->getAssetID()); - // todo: need to trigger send/update once server support is done + LLUUID asset_id = floaterp->getAssetID(); + if (validateAsset(asset_id)) + { + obj->setThumbnailUUID(asset_id); + // todo: need to trigger send/update once server support is done + } + else + { + LLNotificationsUtil::add("ThumbnailDimantionsLimit"); + } } } diff --git a/indra/newview/llfloaterchangeitemthumbnail.h b/indra/newview/llfloaterchangeitemthumbnail.h index 250f895078..bc85e4be0b 100644 --- a/indra/newview/llfloaterchangeitemthumbnail.h +++ b/indra/newview/llfloaterchangeitemthumbnail.h @@ -67,6 +67,8 @@ private: static void onRemove(void*); static void onRemovalConfirmation(const LLSD& notification, const LLSD& response, LLHandle<LLFloater> handle); + static bool validateAsset(const LLUUID &asset_id); + void showTexturePicker(const LLUUID &thumbnail_id); void onTexturePickerCommit(LLUUID id); diff --git a/indra/newview/llfloatersimplesnapshot.cpp b/indra/newview/llfloatersimplesnapshot.cpp index 0bf4bb4fc3..83f4f1ace9 100644 --- a/indra/newview/llfloatersimplesnapshot.cpp +++ b/indra/newview/llfloatersimplesnapshot.cpp @@ -42,7 +42,8 @@ LLSimpleSnapshotFloaterView* gSimpleSnapshotFloaterView = NULL; -const S32 THUMBNAIL_SNAPSHOT_DIM = 256; +const S32 LLFloaterSimpleSnapshot::THUMBNAIL_SNAPSHOT_DIM_MAX = 256; +const S32 LLFloaterSimpleSnapshot::THUMBNAIL_SNAPSHOT_DIM_MIN = 64; // Thumbnail posting coro @@ -176,8 +177,8 @@ void LLFloaterSimpleSnapshot::Impl::updateResolution(void* data) return; } - S32 width = THUMBNAIL_SNAPSHOT_DIM; - S32 height = THUMBNAIL_SNAPSHOT_DIM; + S32 width = THUMBNAIL_SNAPSHOT_DIM_MAX; + S32 height = THUMBNAIL_SNAPSHOT_DIM_MAX; LLSnapshotLivePreview* previewp = getPreviewView(); if (previewp) @@ -342,7 +343,7 @@ void LLFloaterSimpleSnapshot::onSend() LLSnapshotLivePreview* previewp = getPreviewView(); std::string temp_file = gDirUtilp->getTempFilename(); - if (previewp->createUploadFile(temp_file, THUMBNAIL_SNAPSHOT_DIM)) + if (previewp->createUploadFile(temp_file, THUMBNAIL_SNAPSHOT_DIM_MAX, THUMBNAIL_SNAPSHOT_DIM_MIN)) { uploadImageUploadFile(temp_file, mInventoryId, mTaskId); } @@ -365,7 +366,7 @@ void LLFloaterSimpleSnapshot::uploadThumbnail(const std::string &file_path, cons // generate a temp texture file for coroutine std::string temp_file = gDirUtilp->getTempFilename(); U32 codec = LLImageBase::getCodecFromExtension(gDirUtilp->getExtension(file_path)); - if (!LLViewerTextureList::createUploadFile(file_path, temp_file, codec, THUMBNAIL_SNAPSHOT_DIM)) + if (!LLViewerTextureList::createUploadFile(file_path, temp_file, codec, THUMBNAIL_SNAPSHOT_DIM_MAX, THUMBNAIL_SNAPSHOT_DIM_MIN)) { LLSD notif_args; notif_args["REASON"] = LLImage::getLastError().c_str(); diff --git a/indra/newview/llfloatersimplesnapshot.h b/indra/newview/llfloatersimplesnapshot.h index 1b51325afc..7fae5be30a 100644 --- a/indra/newview/llfloatersimplesnapshot.h +++ b/indra/newview/llfloatersimplesnapshot.h @@ -67,6 +67,9 @@ public: class Impl; friend class Impl; + static const S32 LLFloaterSimpleSnapshot::THUMBNAIL_SNAPSHOT_DIM_MAX = 256; + static const S32 LLFloaterSimpleSnapshot::THUMBNAIL_SNAPSHOT_DIM_MIN = 64; + private: void onSend(); void onCancel(); diff --git a/indra/newview/llsnapshotlivepreview.cpp b/indra/newview/llsnapshotlivepreview.cpp index 273e3a403d..37ebcd1266 100644 --- a/indra/newview/llsnapshotlivepreview.cpp +++ b/indra/newview/llsnapshotlivepreview.cpp @@ -874,7 +874,7 @@ LLPointer<LLImageRaw> LLSnapshotLivePreview::getEncodedImage() return mPreviewImageEncoded; } -bool LLSnapshotLivePreview::createUploadFile(const std::string &out_filename, const S32 max_image_dimentions) +bool LLSnapshotLivePreview::createUploadFile(const std::string &out_filename, const S32 max_image_dimentions, const S32 min_image_dimentions) { // make a copy, since convertToUploadFile modifies raw image LLPointer<LLImageRaw> raw_image = new LLImageRaw( @@ -884,6 +884,16 @@ bool LLSnapshotLivePreview::createUploadFile(const std::string &out_filename, co mPreviewImage->getComponents()); LLPointer<LLImageJ2C> compressedImage = LLViewerTextureList::convertToUploadFile(raw_image, max_image_dimentions); + if (compressedImage->getWidth() < min_image_dimentions || compressedImage->getHeight() < min_image_dimentions) + { + std::string reason = llformat("Images below %d x %d pixels are not allowed. Actual size: %d x %dpx", + min_image_dimentions, + min_image_dimentions, + compressedImage->getWidth(), + compressedImage->getHeight()); + compressedImage->setLastError(reason); + return FALSE; + } if (compressedImage.isNull()) { compressedImage->setLastError("Couldn't convert the image to jpeg2000."); diff --git a/indra/newview/llsnapshotlivepreview.h b/indra/newview/llsnapshotlivepreview.h index e78c885789..6e38a957b4 100644 --- a/indra/newview/llsnapshotlivepreview.h +++ b/indra/newview/llsnapshotlivepreview.h @@ -106,7 +106,7 @@ public: LLPointer<LLImageFormatted> getFormattedImage(); LLPointer<LLImageRaw> getEncodedImage(); - bool createUploadFile(const std::string &out_file, const S32 max_image_dimentions); + bool createUploadFile(const std::string &out_file, const S32 max_image_dimentions, const S32 min_image_dimentions); /// Sets size of preview thumbnail image and the surrounding rect. void setThumbnailPlaceholderRect(const LLRect& rect) {mThumbnailPlaceholderRect = rect; } diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp index 93ae1670c8..901747ce57 100644 --- a/indra/newview/llviewertexturelist.cpp +++ b/indra/newview/llviewertexturelist.cpp @@ -1286,7 +1286,8 @@ void LLViewerTextureList::decodeAllImages(F32 max_time) BOOL LLViewerTextureList::createUploadFile(const std::string& filename, const std::string& out_filename, const U8 codec, - const S32 max_image_dimentions) + const S32 max_image_dimentions, + const S32 min_image_dimentions) { LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; // Load the image @@ -1314,6 +1315,16 @@ BOOL LLViewerTextureList::createUploadFile(const std::string& filename, image->setLastError("Image files with less than 3 or more than 4 components are not supported."); return FALSE; } + if (image->getWidth() < min_image_dimentions || image->getHeight() < min_image_dimentions) + { + std::string reason = llformat("Images below %d x %d pixels are not allowed. Actual size: %d x %dpx", + min_image_dimentions, + min_image_dimentions, + image->getWidth(), + image->getHeight()); + image->setLastError(reason); + return FALSE; + } // Convert to j2c (JPEG2000) and save the file locally LLPointer<LLImageJ2C> compressedImage = convertToUploadFile(raw_image, max_image_dimentions); if (compressedImage.isNull()) diff --git a/indra/newview/llviewertexturelist.h b/indra/newview/llviewertexturelist.h index 0018e78d45..eac26ab0eb 100644 --- a/indra/newview/llviewertexturelist.h +++ b/indra/newview/llviewertexturelist.h @@ -95,7 +95,8 @@ public: static BOOL createUploadFile(const std::string& filename, const std::string& out_filename, const U8 codec, - const S32 max_image_dimentions = LLViewerFetchedTexture::MAX_IMAGE_SIZE_DEFAULT); + const S32 max_image_dimentions = LLViewerFetchedTexture::MAX_IMAGE_SIZE_DEFAULT, + const S32 min_image_dimentions = 0); static LLPointer<LLImageJ2C> convertToUploadFile(LLPointer<LLImageRaw> raw_image, const S32 max_image_dimentions = LLViewerFetchedTexture::MAX_IMAGE_SIZE_DEFAULT); static void processImageNotInDatabase( LLMessageSystem *msg, void **user_data ); diff --git a/indra/newview/skins/default/xui/en/floater_change_item_thumbnail.xml b/indra/newview/skins/default/xui/en/floater_change_item_thumbnail.xml index 95e868a696..f3f8ee0daa 100644 --- a/indra/newview/skins/default/xui/en/floater_change_item_thumbnail.xml +++ b/indra/newview/skins/default/xui/en/floater_change_item_thumbnail.xml @@ -44,14 +44,15 @@ top="4" width="16" /> <text - follows="left|top|right" + name="item_name" font="SansSerif" - height="19" + max_length_bytes="127" + use_ellipses="true" + follows="left|top|right" layout="topleft" + height="19" top_delta="1" left_pad="3" - max_length_bytes="127" - name="item_name" width="286"/> <thumbnail diff --git a/indra/newview/skins/default/xui/en/notifications.xml b/indra/newview/skins/default/xui/en/notifications.xml index ceae31967e..d2d3cb4523 100644 --- a/indra/newview/skins/default/xui/en/notifications.xml +++ b/indra/newview/skins/default/xui/en/notifications.xml @@ -6110,6 +6110,17 @@ Are you sure you want to delete them? </notification> <notification + icon="alertmodal.tga" + name="ThumbnailDimantionsLimit" + type="alertmodal"> + <unique/> + Only square images from 64 to 256 pixels per side are allowed. + <usetemplate + name="okbutton" + yestext="OK"/> + </notification> + + <notification icon="alertmodal.tga" name="ConfirmUnlink" type="alertmodal"> |