Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Passing object through jinja converts it to a html encoded text

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!

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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

>Solution :

&#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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading