Skip to content

Add custom icon support for web links#3325

Merged
Salazareo merged 3 commits into
HeyPuter:mainfrom
Adcbda:feature/custom-web-link-icon
Jul 7, 2026
Merged

Add custom icon support for web links#3325
Salazareo merged 3 commits into
HeyPuter:mainfrom
Adcbda:feature/custom-web-link-icon

Conversation

@Adcbda

@Adcbda Adcbda commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add persistent custom icon support for .weblink files.
  • Add a Change Icon context menu action that uses Puter's built-in file picker.
  • Read selected icon files from Puter FS and store them as data URLs in the web link payload.
  • Preserve legacy web links by falling back to the default link icon and upgrading plain-URL web links when edited.

Details

Web link icons were previously hard-coded to link.svg in the item icon resolver. This change centralizes web link parsing and icon handling in src/gui/src/helpers/weblink.js, stores the selected icon in the .weblink JSON, and teaches item_icon to prefer that custom icon when rendering.

The icon picker accepts image files selected through Puter's file manager. Because files read from Puter FS may have a generic Blob MIME type, the helper normalizes data URLs using the selected file type, extension, and image byte signatures for PNG, JPEG, GIF, WebP, and SVG.

Validation

  • npm run build --workspace src/gui

The build passes with the existing webpack bundle size warnings.

Introduce the ability to change and display custom icons for .weblink files. Added a "Change Icon" context menu item that invokes the changeWeblinkIcon helper, and updated the icon rendering logic to use getWeblinkIcon instead of the default link icon. This allows users to personalize web link appearance in the file manager.
@CLAassistant

CLAassistant commented Jun 30, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@Adcbda Adcbda marked this pull request as ready for review June 30, 2026 08:37
Salazareo and others added 2 commits July 7, 2026 13:04
 # UIWindowSearch and require the icon data URL body to be pure base64 in
  #isValidWeblinkIcon. A shared/downloaded .weblink is untrusted input and
 # the previous prefix-only check let a crafted icon break out of the
 # <img src> attribute.
 # byte-signature MIME sniffing and capping stored icon size (was storing
 # full-resolution images as base64).
 # without picking a file.
 # weblinks no longer fetches every file's contents on each render.
 # path instead of the target weblink).
 # label, add the AGPL license header, and drop redundant stored icon
 # copies.
Rasterizing a picked SVG to a 256px PNG threw away its scalability for no
real benefit: an SVG rendered in <img> runs in script-free static mode, and
the base64-body validation already prevents attribute injection. Store SVGs
as data:image/svg+xml;base64 (content-sniffed, size-capped), and keep
rasterizing raster formats and oversized SVGs to bound stored size.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@Salazareo

Copy link
Copy Markdown
Member

pushed some changes to prevent xss and down size some of the images for web links

@Salazareo Salazareo merged commit e1280e8 into HeyPuter:main Jul 7, 2026
6 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants