Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

[API] HTML entities in strings get converted to their ASCII equivalent, often breaking scripts.

October 13 (10 years ago)
The Aaron
Roll20 Production Team
API Scripter
I've noticed this happening since I started working on API scripts. I have yet to find a repeatable case, but it seems to have something to do with when the API page is slow to save a new script. It's possible that it involves refreshing the page before the save process has finished.

Basically, strings like this:
var s='Some string with <something> in angle brackets.';
End up as:
var s='Some string with <something> in angle brackets.';
That means that whenever it is sent to chat, the <something> disappears and you just get the output:
Some string with  in angle brackets.

That presentation of the issue is fairly innocuous, but when it's something like this:
var s='Something that&#39;s worse...';
You end up with 'Unexpected identifier' and the script won't load because it has this line now:
var s='Something that's worse...';

Here's an actual case:



Anyway, don't know what can be done about that, but maybe this description is thorough enough to allow the Devs to figure out where this might be happening.
October 13 (10 years ago)
The Aaron
Roll20 Production Team
API Scripter
It's also possible it's browser or OS based behavior... but I don't think so...
October 13 (10 years ago)

Edited October 13 (10 years ago)
Lithl
Pro
Sheet Author
API Scripter

Regardless of cause, you could do one of the following to avoid the problem (at least in the case of the apostrophes):

var s = 'Something that\'s worse...';
var s = "Something that's worse...";
var s = 'Something that&rsquo;s worse...'; // Note that this is the "curly" apostrophe, instead of the regular character

I'm sure there are other cases where the transformation causes problems, but this particular one is fixable.

October 13 (10 years ago)
The Aaron
Roll20 Production Team
API Scripter
Sure, or I could use ".... ' .... " instead. You are right though, that's not really the point. =D Honestly the < & > get me more often.