This routine shall escape any special characters that may break the JS context and introduce any unwanted evil code due to JS injection. This is based on the OWASP's javascript codec implementation (URL provided the JS comment above).