Home > Blockchain >  Passing object through jinja converts it to a html encoded text
Passing object through jinja converts it to a html encoded text

Time:12-23

why does javascript convert this object:

{'id': '627862713242222632', 'username': 'Piranhas', 'avatar': 'da8a11436b0e596016e98d53688094ba', 'discriminator': '5016', 'public_flags': 0, 'flags': 0, 'banner': None, 'banner_color': None, 'accent_color': None, 'locale': 'en-US', 'mfa_enabled': False}

into the following

{'id': '627862713242222632', 'username': 'Piranhas', 'avatar': 'da8a11436b0e596016e98d53688094ba', 'discriminator': '5016', 'public_flags': 0, 'flags': 0, 'banner': None, 'banner_color': None, 'accent_color': None, 'locale': 'en-US', 'mfa_enabled': False}```
function messageParameters(messageType, userInfo) {
    let parameterTable = document.getElementById("parameterTable");
    console.log(userInfo)

The clean object (the first one) is printed in my python webapp, and then passed through a renderTemplate. However, when it gets to my site (passing into the function) it converts it into a hole load of mess!

Any insight into why this is happening, and a potential fix would be great.

CodePudding user response:

&#39 is the html encoding for an apostrophe. It has replaced all the apostrophes with the encoding to ensure that the browser will correctly display actual apostrophes. If it did not do this, there it the risk that the browser could interpret it as code which would could be a security issue.

  • Related