iGEM Wiki system cannot handle ` & ` in <script> and <style>
with a guide on how to solve this bug
` & ` get rendered as ` &;`.
Internal JS
<script>
if (true && true) {
document.getElementById("internal").innerHTML = "Internal Script Succesfully Executed!;";
}
</script>
This block of code is rendered by the wiki system as the following block.
<script>
if (true &;&; true) {
document.getElementById("internal").innerHTML = "Internal Script Succesfully Executed!";
}
</script>
This bug causes a fatal error, and make ...
Internal Script Not Executed!
External JS
<script src="https://cdn.rawgit.com/na399/5d12928f9d7bb1714faa61be5870d470/raw/b91303bb9b76d700f4990a735acf8bcb1809137f/TestAmpersand.js"></script>
When the same script is hosted externally, ...
External Script Not Executed!
According to
Wiki Dos and Don'ts
partially, retrieved from https://2018.igem.org/Resources/Wiki_Editing_Help on 4 Aug 2018
Do | Don't | Why? |
---|---|---|
Make sure all wiki content is hosted on 2018.igem.org. (This includes text, files, HTML, CSS, Javascript, and other scripts.) | Don't host your wiki or parts of your wiki elsewhere. Don't include scripts or stylesheets from other servers. | iGEM content is preserved on our servers so future teams can learn from what you've done. When content is stored on other sites/servers, links may become broken, sites may go down, and information will be lost. |
Load your CSS and Javascript into the wiki, either directly into your page or using templates. | Don't try to host your CSS and Javascript on a third party server | You are required to host all content on the iGEM servers (see above) |
With this fatal bug, we can't directly use internal JS scripts and CSS styles. We're still able to put them on the iGEM servers, as required, by following the guide below.
External JS hosted on iGEM Server
- You may put your code as is on a new page.
For example, see https://2018.igem.org/Template:UCopenhagen/js/bugAmpersand - Add
?action=raw&ctype=text/javascript
, for JS script, or?action=raw&ctype=text/css
, for CSS style, to the end of the URL earlier Ref 1 .
For example, https://2018.igem.org/Template:UCopenhagen/js/bugAmpersand?action=raw&ctype=text/javascript - Load the script on the desired destination page as an external script.
For example,<script src="https://2018.igem.org/Template:UCopenhagen/js/bugAmpersand?action=raw&ctype=text/javascript"></script>
Now the external JS script is hosted on the iGEM server, ...
External Script hosted on iGEM Server Not Executed!
Ref 1