Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7568797
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T15:00:48+00:00 2026-05-30T15:00:48+00:00

There seems to be a bug when using the JavaScript functions encodeURI / escape

  • 0

There seems to be a bug when using the JavaScript functions encodeURI / escape and encodeURIComponent. Example:

escape( 'The Frames' )             // The            0.000000rames
encodeURI( 'The Frames' )          // The            0.000000rames
encodeURIComponent( 'The Frames' ) // The            0.000000rames

The comments show the output. Executing this code outside of Spotify in whatever browser works as expected (replacing a space by either + or %20).

Can others confirm this is a bug? Or am I doing something wrong here…? Is there a place to report bugs for Spotify Apps?

EDIT: Apparently the examples above work as they are supposed to. However, incorporating them in an alert() will show a messed up string, while in fact it is OK.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T15:00:50+00:00Added an answer on May 30, 2026 at 3:00 pm

    From the guidelines:

    Encoded Strings

    To ensure that applications do not use strings in potentially unsafe ways, all strings given by the Spotify APIs are encoded so that accidental misuse will not cause injection vulnerabilities. If the application does not decode these strings, using the two methods described below, the strings will display as garbage to the user. The only exception to this is URIs, which are never encoded and thus require no decoding. The API documentation states for each method which strings must be decoded or not.
    Two methods have been added to the JavaScript strings: decodeForText() and decodeForHTML(). If the string is intended to be used in a safe manner, such as setting the innerText or creating a text node using document.createTextNode(), the decodeForText() should be used. It will return a raw non-escaped string, so make sure it is never inserted into any context where will be interpreted as HTML. If the string is inteded to go into an innerHTML or in any piece of code that will be intepreted as HTML, the decodeForHTML() must be used. It will ensure that < and > is encoded as < and > etc. For example:


    getElementById('song-title').innerHTML = track.title.decodeForHTML();
    getElementById('song-title').innerText = track.title.decodeForText();
    getElementById('song-title').appendChild(document.createTextNode(track.title.decodeForText()));

    Applications that do not use these methods will a) not be able to display metadata or any other data from the Spotify API, and b) will be rejected in the upload process. Also ensure that you propery escape unsafe HTML strings from wherever they happen to come from, e.g., your backend servers.


    And the source code, in case you’re curious:

    String.prototype.decodeForText = function() {
        var result = "";
        for (var i = 0; i < this.length; ++i) {
            if (this.charAt(i) !== "&") {
                result += this.charAt(i);
                continue;
            } else if (this.substring(i, i + 5) === "&amp;") {
                result += "&";
                i += 4;
                continue;
            } else if (this.substring(i, i + 4) === "&lt;") {
                result += "<";
                i += 3;
                continue;
            } else if (this.substring(i, i + 4) === "&gt;") {
                result += ">";
                i += 3;
                continue;
            } else if (this.substring(i, i + 6) === "&quot;") {
                result += "\"";
                i += 5;
                continue;
            } else if (this.substring(i, i + 6) === "&apos;") {
                result += "'";
                i += 5;
                continue;
            } else if (this.substring(i, i + 8) === "&equals;") {
                result += "=";
                i += 7;
                continue;
            }
        }
        return result;
    };
    
    String.prototype.decodeForHTML = function() {
        return this;
    };
    
    String.prototype.decodeForLink = function() {
        return encodeURI(this.decodeForText());
    }
    
    String.prototype.encodeToHTML = function() {
        var result = "";
        for (var i = 0; i < this.length; ++i) {
            if (this.charAt(i) === "&") {
                result += "&amp;";
            } else if (this.charAt(i) === "<") {
                result += "&lt;";
            } else if (this.charAt(i) === ">") {
                result += "&gt;";
            } else if (this.charAt(i) === "\"") {
                result += "&quot;";
            } else if (this.charAt(i) === "'") {
                result += "&apos;";
            } else if (this.charAt(i) === "=") {
                result += "&equals;";
            } else {
                result += this.charAt(i);
            }
        }
        return result;
    }
    }(this));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

It seems to be well-known there is a bug when using JMenuItem.getRootPane(). I read
[EDIT] It seems that there is a bug in the XML Editor I'm using
There seems to be a bug in a Wordpress PHP function that leaves whitespace
There seems to be a bug in the Java varargs implementation. Java can't distinguish
There seems to be a bug in firefox where if I put anything on
[ Solved , it seems that there was some bug affecting Alfresco 3.3.0, which
There seems to be an issue when using shared pointers together with a custom
It seems there is a known bug in wsdl.exe, the tool that Visual Studio
There seems to be no good way to localize a WPF application. MSDN seems
There seems to be a lot of heated discussion on the net about the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.