Skip to content
This repository was archived by the owner on Dec 5, 2018. It is now read-only.

Conversation

@fdub
Copy link

@fdub fdub commented Sep 29, 2017

Console output should be printed out as is, so a div tag is not a good choice. Using a pre tag, the console outputs are unchanged.

@Pomax
Copy link
Member

Pomax commented Sep 29, 2017

That will not change the interpretation of the strings printed: <...> will still be interpreted as markup, not literal text. What should happen is that data gets "safified" with respect to html entities, so something along the lines of:

var forceHTMLEntities = (function(){
  var converter = document.createElement('div');
  return function(data) {
    converter.textContent = data;
    return converter.innerHTML;
  };
}());

Which is then called using escapedInput = forceHTMLEntities(input) etc

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants