From a526209e747642c9dbd8c0cbe9ec2b5247c35d5e Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Wed, 24 Oct 2012 18:22:45 +0100 Subject: More useful title info for images. --- !NetSurf/Resources/de/Messages | 22 ++++---- !NetSurf/Resources/en/Messages | 22 ++++---- !NetSurf/Resources/fr/Messages | 22 ++++---- !NetSurf/Resources/it/Messages | 22 ++++---- !NetSurf/Resources/nl/Messages | 22 ++++---- Makefile.sources | 2 +- image/bmp.c | 5 +- image/gif.c | 5 +- image/ico.c | 7 ++- image/jpeg.c | 7 ++- image/mng.c | 16 +++--- image/png.c | 5 +- image/webp.c | 5 +- resources/FatMessages | 110 ++++++++++++++++++------------------- riscos/content-handlers/artworks.c | 7 ++- riscos/content-handlers/draw.c | 7 ++- riscos/content-handlers/sprite.c | 7 ++- utils/nsurl.c | 32 +++++++++++ utils/nsurl.h | 14 +++++ 19 files changed, 197 insertions(+), 142 deletions(-) diff --git a/!NetSurf/Resources/de/Messages b/!NetSurf/Resources/de/Messages index 35d8cc24f..97e6e8897 100644 --- a/!NetSurf/Resources/de/Messages +++ b/!NetSurf/Resources/de/Messages @@ -687,17 +687,17 @@ SelectMenu:Auswahl # Content titles # -DrawTitle:Draw Bild (%lux%lu, %lu bytes) -GIFTitle:GIF Bild (%lux%lu, %lu bytes) -BMPTitle:BMP Bild (%lux%lu, %lu bytes) -ICOTitle:ICO Bild (%lux%lu, %lu bytes) -JPEGTitle:JPEG Bild (%ux%u, %lu bytes) -PNGTitle:PNG Bild (%lux%lu, %lu bytes) -JNGTitle:JNG Bild (%lux%lu, %lu bytes) -MNGTitle:MNG Bild (%lux%lu, %lu bytes) -WebPTitle:WebP Bild (%lux%lu, %lu bytes) -SpriteTitle:Sprite Bild (%lux%lu, %lu bytes) -ArtWorksTitle:ArtWorks Bild (%lux%lu, %lu bytes) +GIFTitle:%s (GIF Bild %lux%lu pixels) +BMPTitle:%s (BMP Bild %lux%lu pixels) +ICOTitle:%s (ICO Bild %lux%lu pixels) +PNGTitle:%s (PNG Bild %lux%lu pixels) +JNGTitle:%s (JNG Bild %lux%lu pixels) +MNGTitle:%s (MNG Bild %lux%lu pixels) +JPEGTitle:%s (JPEG Bild %lux%lu pixels) +WebPTitle:%s (WebP Bild %lux%lu pixels) +DrawTitle:%s (Drawfile Bild %lux%lu pixels) +SpriteTitle:%s (Sprite Bild %lux%lu pixels) +ArtWorksTitle:%s (ArtWorks Bild %lux%lu pixels) # HTML page character set # diff --git a/!NetSurf/Resources/en/Messages b/!NetSurf/Resources/en/Messages index 28e197ef0..7ee99ea80 100644 --- a/!NetSurf/Resources/en/Messages +++ b/!NetSurf/Resources/en/Messages @@ -687,17 +687,17 @@ SelectMenu:Select # Content titles # -DrawTitle:Draw image (%lux%lu, %lu bytes) -GIFTitle:GIF image (%lux%lu, %lu bytes) -BMPTitle:BMP image (%lux%lu, %lu bytes) -ICOTitle:ICO image (%lux%lu, %lu bytes) -JPEGTitle:JPEG image (%ux%u, %lu bytes) -PNGTitle:PNG image (%lux%lu, %lu bytes) -JNGTitle:JNG image (%lux%lu, %lu bytes) -MNGTitle:MNG image (%lux%lu, %lu bytes) -WebPTitle:WebP image (%lux%lu, %lu bytes) -SpriteTitle:Sprite image (%lux%lu, %lu bytes) -ArtWorksTitle:ArtWorks image (%lux%lu, %lu bytes) +GIFTitle:%s (GIF image %lux%lu pixels) +BMPTitle:%s (BMP image %lux%lu pixels) +ICOTitle:%s (ICO image %lux%lu pixels) +PNGTitle:%s (PNG image %lux%lu pixels) +JNGTitle:%s (JNG image %lux%lu pixels) +MNGTitle:%s (MNG image %lux%lu pixels) +JPEGTitle:%s (JPEG image %lux%lu pixels) +WebPTitle:%s (WebP image %lux%lu pixels) +DrawTitle:%s (Drawfile image %lux%lu pixels) +SpriteTitle:%s (Sprite image %lux%lu pixels) +ArtWorksTitle:%s (ArtWorks image %lux%lu pixels) # HTML page character set # diff --git a/!NetSurf/Resources/fr/Messages b/!NetSurf/Resources/fr/Messages index 4be370bfe..f6994131e 100644 --- a/!NetSurf/Resources/fr/Messages +++ b/!NetSurf/Resources/fr/Messages @@ -687,17 +687,17 @@ SelectMenu:Sélection # Content titles # -DrawTitle:Image Draw (%lux%lu, %lu octets) -GIFTitle:Image GIF (%lux%lu, %lu octets) -BMPTitle:Image BMP (%lux%lu, %lu octets) -ICOTitle:Image BMP (%lux%lu, %lu octets) -JPEGTitle:Image JPEG (%ux%u, %lu octets) -PNGTitle:Image PNG (%lux%lu, %lu octets) -JNGTitle:Image JNG (%lux%lu, %lu octets) -MNGTitle:Image MNG (%lux%lu, %lu octets) -WebPTitle:Image WebP (%lux%lu, %lu octets) -SpriteTitle:Image Sprite (%lux%lu, %lu octets) -ArtWorksTitle:Image ArtWorks (%lux%lu, %lu octets) +GIFTitle:%s (Image GIF %lux%lu pixels) +BMPTitle:%s (Image BMP %lux%lu pixels) +ICOTitle:%s (Image BMP %lux%lu pixels) +PNGTitle:%s (Image PNG %lux%lu pixels) +JNGTitle:%s (Image JNG %lux%lu pixels) +MNGTitle:%s (Image MNG %lux%lu pixels) +JPEGTitle:%s (Image JPEG %lux%lu pixels) +WebPTitle:%s (Image WebP %lux%lu pixels) +DrawTitle:%s (Image Drawfile %lux%lu pixels) +SpriteTitle:%s (Image Sprite %lux%lu pixels) +ArtWorksTitle:%s (Image ArtWorks %lux%lu pixels) # HTML page character set # diff --git a/!NetSurf/Resources/it/Messages b/!NetSurf/Resources/it/Messages index 9b670170f..cf0728c7c 100644 --- a/!NetSurf/Resources/it/Messages +++ b/!NetSurf/Resources/it/Messages @@ -687,17 +687,17 @@ SelectMenu:Seleziona # Content titles # -DrawTitle:Immagine Draw (%lux%lu, %lu byte) -GIFTitle:Immagine GIF (%lux%lu, %lu byte) -BMPTitle:Immagine BMP (%lux%lu, %lu byte) -ICOTitle:Immagine ICO (%lux%lu, %lu byte) -JPEGTitle:Immagine JPEG (%ux%u, %lu byte) -PNGTitle:Immagine PNG (%lux%lu, %lu byte) -JNGTitle:Immagine JNG (%lux%lu, %lu byte) -MNGTitle:Immagine MNG (%lux%lu, %lu byte) -WebPTitle:Immagine WebP (%lux%lu, %lu byte) -SpriteTitle:Immagine Sprite (%lux%lu, %lu byte) -ArtWorksTitle:Immagine ArtWorks (%lux%lu, %lu byte) +GIFTitle:%s (Immagine GIF %lux%lu pixels) +BMPTitle:%s (Immagine BMP %lux%lu pixels) +ICOTitle:%s (Immagine ICO %lux%lu pixels) +PNGTitle:%s (Immagine PNG %lux%lu pixels) +JNGTitle:%s (Immagine JNG %lux%lu pixels) +MNGTitle:%s (Immagine MNG %lux%lu pixels) +JPEGTitle:%s (Immagine JPEG %lux%lu pixels) +WebPTitle:%s (Immagine WebP %lux%lu pixels) +DrawTitle:%s (Immagine Drawfile %lux%lu pixels) +SpriteTitle:%s (Immagine Sprite %lux%lu pixels) +ArtWorksTitle:%s (Immagine ArtWorks %lux%lu pixels) # HTML page character set # diff --git a/!NetSurf/Resources/nl/Messages b/!NetSurf/Resources/nl/Messages index 06b8f0c0a..8eda66721 100644 --- a/!NetSurf/Resources/nl/Messages +++ b/!NetSurf/Resources/nl/Messages @@ -687,17 +687,17 @@ SelectMenu:Select # Content titles # -DrawTitle:Draw image (%lux%lu, %lu bytes) -GIFTitle:GIF image (%lux%lu, %lu bytes) -BMPTitle:BMP image (%lux%lu, %lu bytes) -ICOTitle:ICO image (%lux%lu, %lu bytes) -JPEGTitle:JPEG image (%ux%u, %lu bytes) -PNGTitle:PNG image (%lux%lu, %lu bytes) -JNGTitle:JNG image (%lux%lu, %lu bytes) -MNGTitle:MNG image (%lux%lu, %lu bytes) -WebPTitle:WebP image (%lux%lu, %lu bytes) -SpriteTitle:Sprite image (%lux%lu, %lu bytes) -ArtWorksTitle:ArtWorks image (%lux%lu, %lu bytes) +GIFTitle:%s (GIF image %lux%lu pixels) +BMPTitle:%s (BMP image %lux%lu pixels) +ICOTitle:%s (ICO image %lux%lu pixels) +PNGTitle:%s (PNG image %lux%lu pixels) +JNGTitle:%s (JNG image %lux%lu pixels) +MNGTitle:%s (MNG image %lux%lu pixels) +JPEGTitle:%s (JPEG image %lux%lu pixels) +WebPTitle:%s (WebP image %lux%lu pixels) +DrawTitle:%s (Drawfile image %lux%lu pixels) +SpriteTitle:%s (Sprite image %lux%lu pixels) +ArtWorksTitle:%s (ArtWorks image %lux%lu pixels) # HTML page character set # diff --git a/Makefile.sources b/Makefile.sources index d7229badc..1e990171b 100644 --- a/Makefile.sources +++ b/Makefile.sources @@ -26,7 +26,7 @@ S_HTTP := challenge.c generics.c primitives.c parameter.c \ S_DESKTOP := cookies.c history_global_core.c hotlist.c knockout.c \ mouse.c options.c plot_style.c print.c search.c searchweb.c \ - scrollbar.c sslcert.c textarea.c thumbnail.c tree.c \ + scrollbar.c sslcert.c textarea.c thumbnail.c tree.c treeview.c \ tree_url_node.c version.c # Javascript sources diff --git a/image/bmp.c b/image/bmp.c index c23f9dd54..5af042d3e 100644 --- a/image/bmp.c +++ b/image/bmp.c @@ -132,7 +132,7 @@ static bool nsbmp_convert(struct content *c) uint32_t swidth; const char *data; unsigned long size; - char title[100]; + char title[512]; /* set the bmp data */ data = content__get_source_data(c, &size); @@ -158,7 +158,8 @@ static bool nsbmp_convert(struct content *c) c->height = bmp->bmp->height; LOG(("BMP width %u height %u", c->width, c->height)); snprintf(title, sizeof(title), messages_get("BMPTitle"), - c->width, c->height, size); + nsurl_access_leaf(llcache_handle_get_url(c->llcache)), + c->width, c->height); content__set_title(c, title); swidth = bmp->bmp->bitmap_callbacks.bitmap_get_bpp(bmp->bmp->bitmap) * bmp->bmp->width; diff --git a/image/gif.c b/image/gif.c index 93316e03e..a33f56200 100644 --- a/image/gif.c +++ b/image/gif.c @@ -242,7 +242,7 @@ static bool nsgif_convert(struct content *c) union content_msg_data msg_data; const char *data; unsigned long size; - char title[100]; + char title[512]; /* Get the animation */ data = content__get_source_data(c, &size); @@ -279,7 +279,8 @@ static bool nsgif_convert(struct content *c) c->width = gif->gif->width; c->height = gif->gif->height; snprintf(title, sizeof(title), messages_get("GIFTitle"), - c->width, c->height, size); + nsurl_access_leaf(llcache_handle_get_url(c->llcache)), + c->width, c->height); content__set_title(c, title); c->size += (gif->gif->width * gif->gif->height * 4) + 16 + 44; diff --git a/image/ico.c b/image/ico.c index b9abd7d1c..ff8f9204c 100644 --- a/image/ico.c +++ b/image/ico.c @@ -100,7 +100,7 @@ static bool nsico_convert(struct content *c) union content_msg_data msg_data; const char *data; unsigned long size; - char title[100]; + char title[512]; /* set the ico data */ data = content__get_source_data(c, &size); @@ -125,8 +125,9 @@ static bool nsico_convert(struct content *c) /* Store our content width and description */ c->width = ico->ico->width; c->height = ico->ico->height; - snprintf(title, sizeof(title), messages_get("ICOTitle"), - c->width, c->height, size); + snprintf(title, sizeof(title), messages_get("ICOTitle"), + nsurl_access_leaf(llcache_handle_get_url(c->llcache)), + c->width, c->height); content__set_title(c, title); c->size += (ico->ico->width * ico->ico->height * 4) + 16 + 44; diff --git a/image/jpeg.c b/image/jpeg.c index 82fde0dd1..7c68fb668 100644 --- a/image/jpeg.c +++ b/image/jpeg.c @@ -289,7 +289,7 @@ static bool nsjpeg_convert(struct content *c) union content_msg_data msg_data; const char *data; unsigned long size; - char title[100]; + char title[512]; /* check image header is valid and get width/height */ data = content__get_source_data(c, &size); @@ -325,8 +325,9 @@ static bool nsjpeg_convert(struct content *c) image_cache_add(c, NULL, jpeg_cache_convert); - snprintf(title, sizeof(title), messages_get("JPEGTitle"), - c->width, c->height, size); + snprintf(title, sizeof(title), messages_get("JPEGTitle"), + nsurl_access_leaf(llcache_handle_get_url(c->llcache)), + c->width, c->height); content__set_title(c, title); content_set_ready(c); diff --git a/image/mng.c b/image/mng.c index 67625f026..9ca9a2d48 100644 --- a/image/mng.c +++ b/image/mng.c @@ -541,7 +541,7 @@ static bool nsmng_convert(struct content *c) nsmng_content *mng = (nsmng_content *) c; mng_retcode status; unsigned long size; - char title[100]; + char title[512]; assert(c != NULL); @@ -556,9 +556,9 @@ static bool nsmng_convert(struct content *c) /* Set the title */ - snprintf(title, sizeof(title), - messages_get("MNGTitle"), - c->width, c->height, size); + snprintf(title, sizeof(title), messages_get("MNGTitle"), + nsurl_access_leaf(llcache_handle_get_url(c->llcache)), + c->width, c->height); content__set_title(c, title); c->size += c->width * c->height * 4; @@ -599,7 +599,7 @@ static bool nsjpng_convert(struct content *c) nsmng_content *mng = (nsmng_content *) c; mng_retcode status; unsigned long size; - char title[100]; + char title[512]; mng_handle handle; assert(c != NULL); @@ -614,9 +614,9 @@ static bool nsjpng_convert(struct content *c) } /* Set the title */ - snprintf(title, sizeof(title), - messages_get("PNGTitle"), - c->width, c->height, size); + snprintf(title, sizeof(title), messages_get("PNGTitle"), + nsurl_access_leaf(llcache_handle_get_url(c->llcache)), + c->width, c->height); content__set_title(c, title); c->size += c->width * c->height * 4; diff --git a/image/png.c b/image/png.c index 6f1d926ee..99482d63d 100644 --- a/image/png.c +++ b/image/png.c @@ -510,7 +510,7 @@ png_cache_convert_error: static bool nspng_convert(struct content *c) { nspng_content *png_c = (nspng_content *) c; - char title[100]; + char title[512]; assert(png_c->png != NULL); assert(png_c->info != NULL); @@ -520,7 +520,8 @@ static bool nspng_convert(struct content *c) /* set title text */ snprintf(title, sizeof(title), messages_get("PNGTitle"), - c->width, c->height, c->size); + nsurl_access_leaf(llcache_handle_get_url(c->llcache)), + c->width, c->height); content__set_title(c, title); diff --git a/image/webp.c b/image/webp.c index 080cf8bb0..acf226b5f 100644 --- a/image/webp.c +++ b/image/webp.c @@ -78,7 +78,7 @@ static bool webp_convert(struct content *c) unsigned char *imagebuf = NULL; unsigned long size; int width = 0, height = 0; - char title[100]; + char title[512]; int res = 0; uint8_t *res_p = NULL; @@ -117,7 +117,8 @@ static bool webp_convert(struct content *c) c->width = width; c->height = height; snprintf(title, sizeof(title), messages_get("WebPTitle"), - width, height, size); + nsurl_access_leaf(llcache_handle_get_url(c->llcache)), + c->width, c->height); content__set_title(c, title); bitmap_modified(webp->bitmap); diff --git a/resources/FatMessages b/resources/FatMessages index c2988a590..70d8f9698 100644 --- a/resources/FatMessages +++ b/resources/FatMessages @@ -2323,61 +2323,61 @@ nl.all.SelectMenu:Select # Content titles # -en.all.DrawTitle:Draw image (%lux%lu, %lu bytes) -de.all.DrawTitle:Draw Bild (%lux%lu, %lu bytes) -fr.all.DrawTitle:Image Draw (%lux%lu, %lu octets) -it.all.DrawTitle:Immagine Draw (%lux%lu, %lu byte) -nl.all.DrawTitle:Draw image (%lux%lu, %lu bytes) -en.all.GIFTitle:GIF image (%lux%lu, %lu bytes) -de.all.GIFTitle:GIF Bild (%lux%lu, %lu bytes) -fr.all.GIFTitle:Image GIF (%lux%lu, %lu octets) -it.all.GIFTitle:Immagine GIF (%lux%lu, %lu byte) -nl.all.GIFTitle:GIF image (%lux%lu, %lu bytes) -en.all.BMPTitle:BMP image (%lux%lu, %lu bytes) -de.all.BMPTitle:BMP Bild (%lux%lu, %lu bytes) -fr.all.BMPTitle:Image BMP (%lux%lu, %lu octets) -it.all.BMPTitle:Immagine BMP (%lux%lu, %lu byte) -nl.all.BMPTitle:BMP image (%lux%lu, %lu bytes) -en.all.ICOTitle:ICO image (%lux%lu, %lu bytes) -de.all.ICOTitle:ICO Bild (%lux%lu, %lu bytes) -fr.all.ICOTitle:Image BMP (%lux%lu, %lu octets) -it.all.ICOTitle:Immagine ICO (%lux%lu, %lu byte) -nl.all.ICOTitle:ICO image (%lux%lu, %lu bytes) -en.all.JPEGTitle:JPEG image (%ux%u, %lu bytes) -de.all.JPEGTitle:JPEG Bild (%ux%u, %lu bytes) -fr.all.JPEGTitle:Image JPEG (%ux%u, %lu octets) -it.all.JPEGTitle:Immagine JPEG (%ux%u, %lu byte) -nl.all.JPEGTitle:JPEG image (%ux%u, %lu bytes) -en.all.PNGTitle:PNG image (%lux%lu, %lu bytes) -de.all.PNGTitle:PNG Bild (%lux%lu, %lu bytes) -fr.all.PNGTitle:Image PNG (%lux%lu, %lu octets) -it.all.PNGTitle:Immagine PNG (%lux%lu, %lu byte) -nl.all.PNGTitle:PNG image (%lux%lu, %lu bytes) -en.all.JNGTitle:JNG image (%lux%lu, %lu bytes) -de.all.JNGTitle:JNG Bild (%lux%lu, %lu bytes) -fr.all.JNGTitle:Image JNG (%lux%lu, %lu octets) -it.all.JNGTitle:Immagine JNG (%lux%lu, %lu byte) -nl.all.JNGTitle:JNG image (%lux%lu, %lu bytes) -en.all.MNGTitle:MNG image (%lux%lu, %lu bytes) -de.all.MNGTitle:MNG Bild (%lux%lu, %lu bytes) -fr.all.MNGTitle:Image MNG (%lux%lu, %lu octets) -it.all.MNGTitle:Immagine MNG (%lux%lu, %lu byte) -nl.all.MNGTitle:MNG image (%lux%lu, %lu bytes) -en.all.WebPTitle:WebP image (%lux%lu, %lu bytes) -de.all.WebPTitle:WebP Bild (%lux%lu, %lu bytes) -fr.all.WebPTitle:Image WebP (%lux%lu, %lu octets) -it.all.WebPTitle:Immagine WebP (%lux%lu, %lu byte) -nl.all.WebPTitle:WebP image (%lux%lu, %lu bytes) -en.all.SpriteTitle:Sprite image (%lux%lu, %lu bytes) -de.all.SpriteTitle:Sprite Bild (%lux%lu, %lu bytes) -fr.all.SpriteTitle:Image Sprite (%lux%lu, %lu octets) -it.all.SpriteTitle:Immagine Sprite (%lux%lu, %lu byte) -nl.all.SpriteTitle:Sprite image (%lux%lu, %lu bytes) -en.all.ArtWorksTitle:ArtWorks image (%lux%lu, %lu bytes) -de.all.ArtWorksTitle:ArtWorks Bild (%lux%lu, %lu bytes) -fr.all.ArtWorksTitle:Image ArtWorks (%lux%lu, %lu octets) -it.all.ArtWorksTitle:Immagine ArtWorks (%lux%lu, %lu byte) -nl.all.ArtWorksTitle:ArtWorks image (%lux%lu, %lu bytes) +en.all.DrawTitle:%s (Draw image %lux%lu pixels) +de.all.DrawTitle:%s (Draw Bild %lux%lu pixels) +fr.all.DrawTitle:%s (Image Draw %lux%lu pixels) +it.all.DrawTitle:%s (Immagine Draw %lux%lu pixels) +nl.all.DrawTitle:%s (Draw image %lux%lu pixels) +en.all.GIFTitle:%s (GIF image %lux%lu pixels) +de.all.GIFTitle:%s (GIF Bild %lux%lu pixels) +fr.all.GIFTitle:%s (Image GIF %lux%lu pixels) +it.all.GIFTitle:%s (Immagine GIF %lux%lu pixels) +nl.all.GIFTitle:%s (GIF image %lux%lu pixels) +en.all.BMPTitle:%s (BMP image %lux%lu pixels) +de.all.BMPTitle:%s (BMP Bild %lux%lu pixels) +fr.all.BMPTitle:%s (Image BMP %lux%lu pixels) +it.all.BMPTitle:%s (Immagine BMP %lux%lu pixels) +nl.all.BMPTitle:%s (BMP image %lux%lu pixels) +en.all.ICOTitle:%s (ICO image %lux%lu pixels) +de.all.ICOTitle:%s (ICO Bild %lux%lu pixels) +fr.all.ICOTitle:%s (Image BMP %lux%lu pixels) +it.all.ICOTitle:%s (Immagine ICO %lux%lu pixels) +nl.all.ICOTitle:%s (ICO image %lux%lu pixels) +en.all.JPEGTitle:%s (JPEG image %lux%lu pixels) +de.all.JPEGTitle:%s (JPEG Bild %lux%lu pixels) +fr.all.JPEGTitle:%s (Image JPEG %lux%lu pixels) +it.all.JPEGTitle:%s (Immagine JPEG %lux%lu pixels) +nl.all.JPEGTitle:%s (JPEG image %lux%lu pixels) +en.all.PNGTitle:%s (PNG image %lux%lu pixels) +de.all.PNGTitle:%s (PNG Bild %lux%lu pixels) +fr.all.PNGTitle:%s (Image PNG %lux%lu pixels) +it.all.PNGTitle:%s (Immagine PNG %lux%lu pixels) +nl.all.PNGTitle:%s (PNG image %lux%lu pixels) +en.all.JNGTitle:%s (JNG image %lux%lu pixels) +de.all.JNGTitle:%s (JNG Bild %lux%lu pixels) +fr.all.JNGTitle:%s (Image JNG %lux%lu pixels) +it.all.JNGTitle:%s (Immagine JNG %lux%lu pixels) +nl.all.JNGTitle:%s (JNG image %lux%lu pixels) +en.all.MNGTitle:%s (MNG image %lux%lu pixels) +de.all.MNGTitle:%s (MNG Bild %lux%lu pixels) +fr.all.MNGTitle:%s (Image MNG %lux%lu pixels) +it.all.MNGTitle:%s (Immagine MNG %lux%lu pixels) +nl.all.MNGTitle:%s (MNG image %lux%lu pixels) +en.all.WebPTitle:%s (WebP image %lux%lu pixels) +de.all.WebPTitle:%s (WebP Bild %lux%lu pixels) +fr.all.WebPTitle:%s (Image WebP %lux%lu pixels) +it.all.WebPTitle:%s (Immagine WebP %lux%lu pixels) +nl.all.WebPTitle:%s (WebP image %lux%lu pixels) +en.all.SpriteTitle:%s (Sprite image %lux%lu pixels) +de.all.SpriteTitle:%s (Sprite Bild %lux%lu pixels) +fr.all.SpriteTitle:%s (Image Sprite %lux%lu pixels) +it.all.SpriteTitle:%s (Immagine Sprite %lux%lu pixels) +nl.all.SpriteTitle:%s (Sprite image %lux%lu pixels) +en.all.ArtWorksTitle:%s (ArtWorks image %lux%lu pixels) +de.all.ArtWorksTitle:%s (ArtWorks Bild %lux%lu pixels) +fr.all.ArtWorksTitle:%s (Image ArtWorks %lux%lu pixels) +it.all.ArtWorksTitle:%s (Immagine ArtWorks %lux%lu pixels) +nl.all.ArtWorksTitle:%s (ArtWorks image %lux%lu pixels) # HTML page character set # diff --git a/riscos/content-handlers/artworks.c b/riscos/content-handlers/artworks.c index 66808d42a..af1a3773c 100644 --- a/riscos/content-handlers/artworks.c +++ b/riscos/content-handlers/artworks.c @@ -172,7 +172,7 @@ bool artworks_convert(struct content *c) void *init_routine; os_error *error; int used = -1; /* slightly better with older OSLib versions */ - char title[100]; + char title[512]; /* check whether AWViewer has been seen and we can therefore locate the ArtWorks rendering modules */ @@ -263,8 +263,9 @@ bool artworks_convert(struct content *c) c->width = (aw->x1 - aw->x0) / 512; c->height = (aw->y1 - aw->y0) / 512; - snprintf(title, sizeof(title), messages_get("ArtWorksTitle"), - c->width, c->height, source_size); + snprintf(title, sizeof(title), messages_get("ArtWorksTitle"), + nsurl_access_leaf(llcache_handle_get_url(c->llcache)), + c->width, c->height); content__set_title(c, title); content_set_ready(c); content_set_done(c); diff --git a/riscos/content-handlers/draw.c b/riscos/content-handlers/draw.c index d18d580cd..1d5a6b5d3 100644 --- a/riscos/content-handlers/draw.c +++ b/riscos/content-handlers/draw.c @@ -113,7 +113,7 @@ bool draw_convert(struct content *c) const void *data; os_box bbox; os_error *error; - char title[100]; + char title[512]; source_data = content__get_source_data(c, &source_size); data = source_data; @@ -141,8 +141,9 @@ bool draw_convert(struct content *c) draw->x0 = bbox.x0; draw->y0 = bbox.y0; - snprintf(title, sizeof(title), messages_get("DrawTitle"), c->width, - c->height, source_size); + snprintf(title, sizeof(title), messages_get("DrawTitle"), + nsurl_access_leaf(llcache_handle_get_url(c->llcache)), + c->width, c->height); content__set_title(c, title); content_set_ready(c); diff --git a/riscos/content-handlers/sprite.c b/riscos/content-handlers/sprite.c index 9a70ebe75..96642d13d 100644 --- a/riscos/content-handlers/sprite.c +++ b/riscos/content-handlers/sprite.c @@ -111,7 +111,7 @@ bool sprite_convert(struct content *c) const char *source_data; unsigned long source_size; const void *sprite_data; - char title[100]; + char title[512]; source_data = content__get_source_data(c, &source_size); @@ -140,8 +140,9 @@ bool sprite_convert(struct content *c) c->width = w; c->height = h; - snprintf(title, sizeof(title), messages_get("SpriteTitle"), c->width, - c->height, source_size); + snprintf(title, sizeof(title), messages_get("SpriteTitle"), + nsurl_access_leaf(llcache_handle_get_url(c->llcache)), + c->width, c->height); content__set_title(c, title); content_set_ready(c); content_set_done(c); diff --git a/utils/nsurl.c b/utils/nsurl.c index 47b7f5451..8c525452a 100644 --- a/utils/nsurl.c +++ b/utils/nsurl.c @@ -1563,6 +1563,38 @@ const char *nsurl_access(const nsurl *url) } +/* exported interface, documented in nsurl.h */ +const char *nsurl_access_leaf(const nsurl *url) +{ + size_t path_len; + const char *path; + const char *leaf; + + if (url->components.path == NULL) + return ""; + + path = lwc_string_data(url->components.path); + path_len = lwc_string_length(url->components.path); + + if (path_len == 0) + return ""; + + if (path_len == 1 && *path == '/') + return "/"; + + leaf = path + path_len; + + do { + leaf--; + } while ((leaf != path) && (*leaf != '/')); + + if (*leaf == '/') + leaf++; + + return leaf; +} + + /* exported interface, documented in nsurl.h */ size_t nsurl_length(const nsurl *url) { diff --git a/utils/nsurl.h b/utils/nsurl.h index 068d08b8d..b075c42a1 100644 --- a/utils/nsurl.h +++ b/utils/nsurl.h @@ -182,6 +182,20 @@ bool nsurl_has_component(const nsurl *url, nsurl_component part); const char *nsurl_access(const nsurl *url); +/** + * Access a URL's path leaf as a string + * + * \param url NetSurf URL to retrieve a string pointer for. + * \return the required string + * + * The returned string is owned by the NetSurf URL object. It will die + * with the NetSurf URL object. Keep a reference to the URL if you need it. + * + * The returned string has a trailing '\0'. + */ +const char *nsurl_access_leaf(const nsurl *url); + + /** * Find the length of a NetSurf URL object's URL, as returned by nsurl_access * -- cgit v1.2.3 From 0b7db9b47adaf56ae937415040cf585a07eaf8cb Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Wed, 24 Oct 2012 18:43:59 +0100 Subject: treeview.c hasn't been pushed yet. --- Makefile.sources | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.sources b/Makefile.sources index 1e990171b..0c2356c0b 100644 --- a/Makefile.sources +++ b/Makefile.sources @@ -26,7 +26,7 @@ S_HTTP := challenge.c generics.c primitives.c parameter.c \ S_DESKTOP := cookies.c history_global_core.c hotlist.c knockout.c \ mouse.c options.c plot_style.c print.c search.c searchweb.c \ - scrollbar.c sslcert.c textarea.c thumbnail.c tree.c treeview.c \ + scrollbar.c sslcert.c textarea.c thumbnail.c tree.c \ tree_url_node.c version.c # Javascript sources -- cgit v1.2.3 From baf50cec89d10055217a3bb210d389694fb1d389 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Thu, 25 Oct 2012 11:12:41 +0100 Subject: make image content handlers title setting use the heap instead of the stack and remove the possibility of buffer overruns --- image/bmp.c | 16 ++++++++++------ image/gif.c | 15 ++++++++++----- image/ico.c | 15 ++++++++++----- image/jpeg.c | 10 +++++++--- image/mng.c | 24 +++++++++++++++--------- image/nssprite.c | 13 +++++++++---- image/png.c | 10 ++++++---- image/webp.c | 11 ++++++++--- 8 files changed, 75 insertions(+), 39 deletions(-) diff --git a/image/bmp.c b/image/bmp.c index 5af042d3e..946bca83b 100644 --- a/image/bmp.c +++ b/image/bmp.c @@ -132,7 +132,7 @@ static bool nsbmp_convert(struct content *c) uint32_t swidth; const char *data; unsigned long size; - char title[512]; + char *title; /* set the bmp data */ data = content__get_source_data(c, &size); @@ -156,15 +156,19 @@ static bool nsbmp_convert(struct content *c) /* Store our content width and description */ c->width = bmp->bmp->width; c->height = bmp->bmp->height; - LOG(("BMP width %u height %u", c->width, c->height)); - snprintf(title, sizeof(title), messages_get("BMPTitle"), - nsurl_access_leaf(llcache_handle_get_url(c->llcache)), - c->width, c->height); - content__set_title(c, title); swidth = bmp->bmp->bitmap_callbacks.bitmap_get_bpp(bmp->bmp->bitmap) * bmp->bmp->width; c->size += (swidth * bmp->bmp->height) + 16 + 44; + /* set title text */ + title = messages_get_buff("BMPTitle", + nsurl_access_leaf(llcache_handle_get_url(c->llcache)), + c->width, c->height); + if (title != NULL) { + content__set_title(c, title); + free(title); + } + /* exit as a success */ bmp->bitmap = bmp->bmp->bitmap; bitmap_modified(bmp->bitmap); diff --git a/image/gif.c b/image/gif.c index a33f56200..704c9710b 100644 --- a/image/gif.c +++ b/image/gif.c @@ -242,7 +242,7 @@ static bool nsgif_convert(struct content *c) union content_msg_data msg_data; const char *data; unsigned long size; - char title[512]; + char *title; /* Get the animation */ data = content__get_source_data(c, &size); @@ -275,14 +275,19 @@ static bool nsgif_convert(struct content *c) return false; } - /* Store our content width and description */ + /* Store our content width, height and calculate size */ c->width = gif->gif->width; c->height = gif->gif->height; - snprintf(title, sizeof(title), messages_get("GIFTitle"), + c->size += (gif->gif->width * gif->gif->height * 4) + 16 + 44; + + /* set title text */ + title = messages_get_buff("GIFTitle", nsurl_access_leaf(llcache_handle_get_url(c->llcache)), c->width, c->height); - content__set_title(c, title); - c->size += (gif->gif->width * gif->gif->height * 4) + 16 + 44; + if (title != NULL) { + content__set_title(c, title); + free(title); + } /* Schedule the animation if we have one */ gif->current_frame = 0; diff --git a/image/ico.c b/image/ico.c index ff8f9204c..e455a59d9 100644 --- a/image/ico.c +++ b/image/ico.c @@ -100,7 +100,7 @@ static bool nsico_convert(struct content *c) union content_msg_data msg_data; const char *data; unsigned long size; - char title[512]; + char *title; /* set the ico data */ data = content__get_source_data(c, &size); @@ -122,14 +122,19 @@ static bool nsico_convert(struct content *c) return false; } - /* Store our content width and description */ + /* Store our content width, height and calculate size */ c->width = ico->ico->width; c->height = ico->ico->height; - snprintf(title, sizeof(title), messages_get("ICOTitle"), + c->size += (ico->ico->width * ico->ico->height * 4) + 16 + 44; + + /* set title text */ + title = messages_get_buff("ICOTitle", nsurl_access_leaf(llcache_handle_get_url(c->llcache)), c->width, c->height); - content__set_title(c, title); - c->size += (ico->ico->width * ico->ico->height * 4) + 16 + 44; + if (title != NULL) { + content__set_title(c, title); + free(title); + } /* select largest icon to ensure one can be selected */ bmp = ico_find(ico->ico, 255, 255); diff --git a/image/jpeg.c b/image/jpeg.c index 7c68fb668..fd18238f7 100644 --- a/image/jpeg.c +++ b/image/jpeg.c @@ -289,7 +289,7 @@ static bool nsjpeg_convert(struct content *c) union content_msg_data msg_data; const char *data; unsigned long size; - char title[512]; + char *title; /* check image header is valid and get width/height */ data = content__get_source_data(c, &size); @@ -325,10 +325,14 @@ static bool nsjpeg_convert(struct content *c) image_cache_add(c, NULL, jpeg_cache_convert); - snprintf(title, sizeof(title), messages_get("JPEGTitle"), + /* set title text */ + title = messages_get_buff("JPEGTitle", nsurl_access_leaf(llcache_handle_get_url(c->llcache)), c->width, c->height); - content__set_title(c, title); + if (title != NULL) { + content__set_title(c, title); + free(title); + } content_set_ready(c); content_set_done(c); diff --git a/image/mng.c b/image/mng.c index 9ca9a2d48..518dc8552 100644 --- a/image/mng.c +++ b/image/mng.c @@ -541,7 +541,7 @@ static bool nsmng_convert(struct content *c) nsmng_content *mng = (nsmng_content *) c; mng_retcode status; unsigned long size; - char title[512]; + char *title; assert(c != NULL); @@ -554,12 +554,15 @@ static bool nsmng_convert(struct content *c) return nsmng_broadcast_error(mng, -1) == NSERROR_OK; } - /* Set the title - */ - snprintf(title, sizeof(title), messages_get("MNGTitle"), + + /* set title text */ + title = messages_get_buff("MNGTitle", nsurl_access_leaf(llcache_handle_get_url(c->llcache)), c->width, c->height); - content__set_title(c, title); + if (title != NULL) { + content__set_title(c, title); + free(title); + } c->size += c->width * c->height * 4; content_set_ready(c); @@ -599,7 +602,7 @@ static bool nsjpng_convert(struct content *c) nsmng_content *mng = (nsmng_content *) c; mng_retcode status; unsigned long size; - char title[512]; + char *title; mng_handle handle; assert(c != NULL); @@ -613,11 +616,14 @@ static bool nsjpng_convert(struct content *c) return nsmng_broadcast_error(mng, -1) == NSERROR_OK; } - /* Set the title */ - snprintf(title, sizeof(title), messages_get("PNGTitle"), + /* set title text */ + title = messages_get_buff("PNGTitle", nsurl_access_leaf(llcache_handle_get_url(c->llcache)), c->width, c->height); - content__set_title(c, title); + if (title != NULL) { + content__set_title(c, title); + free(title); + } c->size += c->width * c->height * 4; content_set_ready(c); diff --git a/image/nssprite.c b/image/nssprite.c index ea05c8fe0..5f05c940a 100644 --- a/image/nssprite.c +++ b/image/nssprite.c @@ -98,7 +98,7 @@ static bool nssprite_convert(struct content *c) const char *data; unsigned long size; - char title[100]; + char *title; data = content__get_source_data(c, &size); @@ -144,9 +144,14 @@ static bool nssprite_convert(struct content *c) c->width = sprite->width; c->height = sprite->height; - snprintf(title, sizeof(title), messages_get("SpriteTitle"), - c->width, c->height, size); - content__set_title(c, title); + /* set title text */ + title = messages_get_buff("SpriteTitle", + nsurl_access_leaf(llcache_handle_get_url(c->llcache)), + c->width, c->height); + if (title != NULL) { + content__set_title(c, title); + free(title); + } bitmap_modified(nssprite->bitmap); diff --git a/image/png.c b/image/png.c index 99482d63d..23c755825 100644 --- a/image/png.c +++ b/image/png.c @@ -510,7 +510,7 @@ png_cache_convert_error: static bool nspng_convert(struct content *c) { nspng_content *png_c = (nspng_content *) c; - char title[512]; + char *title; assert(png_c->png != NULL); assert(png_c->info != NULL); @@ -519,11 +519,13 @@ static bool nspng_convert(struct content *c) png_destroy_read_struct(&png_c->png, &png_c->info, 0); /* set title text */ - snprintf(title, sizeof(title), messages_get("PNGTitle"), + title = messages_get_buff("PNGTitle", nsurl_access_leaf(llcache_handle_get_url(c->llcache)), c->width, c->height); - - content__set_title(c, title); + if (title != NULL) { + content__set_title(c, title); + free(title); + } if (png_c->bitmap != NULL) { bitmap_set_opaque(png_c->bitmap, bitmap_test_opaque(png_c->bitmap)); diff --git a/image/webp.c b/image/webp.c index acf226b5f..fc4356c01 100644 --- a/image/webp.c +++ b/image/webp.c @@ -78,7 +78,7 @@ static bool webp_convert(struct content *c) unsigned char *imagebuf = NULL; unsigned long size; int width = 0, height = 0; - char title[512]; + char *title; int res = 0; uint8_t *res_p = NULL; @@ -116,10 +116,15 @@ static bool webp_convert(struct content *c) c->width = width; c->height = height; - snprintf(title, sizeof(title), messages_get("WebPTitle"), + + /* set title */ + title = messages_get_buff("WebPTitle", nsurl_access_leaf(llcache_handle_get_url(c->llcache)), c->width, c->height); - content__set_title(c, title); + if (title != NULL) { + content__set_title(c, title); + free(title); + } bitmap_modified(webp->bitmap); -- cgit v1.2.3 From 33d40a08af97bae7e12164c5df5c3d2029dcf182 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Thu, 25 Oct 2012 12:05:12 +0100 Subject: Unstackify RISC OS content handler's title setting. --- riscos/content-handlers/artworks.c | 9 ++++++--- riscos/content-handlers/draw.c | 10 +++++++--- riscos/content-handlers/sprite.c | 11 ++++++++--- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/riscos/content-handlers/artworks.c b/riscos/content-handlers/artworks.c index af1a3773c..80733c680 100644 --- a/riscos/content-handlers/artworks.c +++ b/riscos/content-handlers/artworks.c @@ -172,7 +172,7 @@ bool artworks_convert(struct content *c) void *init_routine; os_error *error; int used = -1; /* slightly better with older OSLib versions */ - char title[512]; + char *title; /* check whether AWViewer has been seen and we can therefore locate the ArtWorks rendering modules */ @@ -263,10 +263,13 @@ bool artworks_convert(struct content *c) c->width = (aw->x1 - aw->x0) / 512; c->height = (aw->y1 - aw->y0) / 512; - snprintf(title, sizeof(title), messages_get("ArtWorksTitle"), + title = messages_get_buff("ArtWorksTitle", nsurl_access_leaf(llcache_handle_get_url(c->llcache)), c->width, c->height); - content__set_title(c, title); + if (title != NULL) { + content__set_title(c, title); + free(title); + } content_set_ready(c); content_set_done(c); /* Done: update status bar */ diff --git a/riscos/content-handlers/draw.c b/riscos/content-handlers/draw.c index 1d5a6b5d3..552423980 100644 --- a/riscos/content-handlers/draw.c +++ b/riscos/content-handlers/draw.c @@ -113,7 +113,7 @@ bool draw_convert(struct content *c) const void *data; os_box bbox; os_error *error; - char title[512]; + char *title; source_data = content__get_source_data(c, &source_size); data = source_data; @@ -141,10 +141,14 @@ bool draw_convert(struct content *c) draw->x0 = bbox.x0; draw->y0 = bbox.y0; - snprintf(title, sizeof(title), messages_get("DrawTitle"), + + title = messages_get_buff("DrawTitle", nsurl_access_leaf(llcache_handle_get_url(c->llcache)), c->width, c->height); - content__set_title(c, title); + if (title != NULL) { + content__set_title(c, title); + free(title); + } content_set_ready(c); content_set_done(c); diff --git a/riscos/content-handlers/sprite.c b/riscos/content-handlers/sprite.c index 96642d13d..3d669ad2d 100644 --- a/riscos/content-handlers/sprite.c +++ b/riscos/content-handlers/sprite.c @@ -111,7 +111,7 @@ bool sprite_convert(struct content *c) const char *source_data; unsigned long source_size; const void *sprite_data; - char title[512]; + char *title; source_data = content__get_source_data(c, &source_size); @@ -140,10 +140,15 @@ bool sprite_convert(struct content *c) c->width = w; c->height = h; - snprintf(title, sizeof(title), messages_get("SpriteTitle"), + + /* set title text */ + title = messages_get_buff("SpriteTitle", nsurl_access_leaf(llcache_handle_get_url(c->llcache)), c->width, c->height); - content__set_title(c, title); + if (title != NULL) { + content__set_title(c, title); + free(title); + } content_set_ready(c); content_set_done(c); /* Done: update status bar */ -- cgit v1.2.3