brave / brave-browser

Brave browser for Android, iOS, Linux, macOS, Windows.
https://brave.com
Mozilla Public License 2.0
17.7k stars 2.31k forks source link

Brave Wallet does not display token icons that use data URLs #41104

Open 2dpetkov opened 3 weeks ago

2dpetkov commented 3 weeks ago

Description

When tokens that use data:image/svg+xml type of URLs are imported in the Icon URL filed in Brave Wallet, the wallet fails to display the icon.

Steps to reproduce

  1. Open brave://wallet
  2. Navigate to Portfolio tab
  3. Find the Visible Assets icon image
  4. Click on the Available Assets option at the top. image
  5. Select Add custom asset image
  6. Fill in the fields with token details image
  7. Update Icon URL to
    data:image/svg+xml,%3Csvg width='32' height='32' viewBox='0 0 32 32' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none'%3E%3Ccircle cx='16' cy='16' r='16' fill='%232775C9'/%3E%3Cpath d='M15.75 27.5C9.26 27.5 4 22.24 4 15.75S9.26 4 15.75 4 27.5 9.26 27.5 15.75A11.75 11.75 0 0115.75 27.5zm-.7-16.11a2.58 2.58 0 00-2.45 2.47c0 1.21.74 2 2.31 2.33l1.1.26c1.07.25 1.51.61 1.51 1.22s-.77 1.21-1.77 1.21a1.9 1.9 0 01-1.8-.91.68.68 0 00-.61-.39h-.59a.35.35 0 00-.28.41 2.73 2.73 0 002.61 2.08v.84a.705.705 0 001.41 0v-.85a2.62 2.62 0 002.59-2.58c0-1.27-.73-2-2.46-2.37l-1-.22c-1-.25-1.47-.58-1.47-1.14 0-.56.6-1.18 1.6-1.18a1.64 1.64 0 011.59.81.8.8 0 00.72.46h.47a.42.42 0 00.31-.5 2.65 2.65 0 00-2.38-2v-.69a.705.705 0 00-1.41 0v.74zm-8.11 4.36a8.79 8.79 0 006 8.33h.14a.45.45 0 00.45-.45v-.21a.94.94 0 00-.58-.87 7.36 7.36 0 010-13.65.93.93 0 00.58-.86v-.23a.42.42 0 00-.56-.4 8.79 8.79 0 00-6.03 8.34zm17.62 0a8.79 8.79 0 00-6-8.32h-.15a.47.47 0 00-.47.47v.15a1 1 0 00.61.9 7.36 7.36 0 010 13.64 1 1 0 00-.6.89v.17a.47.47 0 00.62.44 8.79 8.79 0 005.99-8.34z' fill='%23FFF'/%3E%3C/g%3E%3C/svg%3E
  8. Save

Actual result

No icon gets displayed in the Portfolio screen, as well as any other place that should be displaying the token icon

image

Expected result

data:image/svg+xml are valid URLs, so having such values in the Icon URL field should lead to icons being visible

Reproduces how often

Easily reproduced

Brave version (brave://version info)

1.69.168 Chromium: 128.0.6613.138 (Official Build) (arm64)

image

Channel information

Reproducibility

Miscellaneous information

No response

lampamazaza commented 2 weeks ago

image/jpeg;base64,/9j/4AAQSk...

Same for this format