airbnb/hypernova

Encode closing Tag

オープン

#165 opened on 2019/10/09

 (8 件のコメント) (4 件のリアクション) (0 人の担当者)JavaScript (216 件のフォーク)batch import
bughelp wanted

Repository metrics

Stars
 (5,784 個のスター)
PR merge metrics
 (PR metrics pending)

説明

Currently encoding in the index.js only includes

const ENCODE = [
  ['&', '&'],
  ['>', '>'],
];

If a component is being rendered SSR and includes a property with a closing script tag, the script tag in the SSrendered HTML will close the hypernova script.

<script type="application/json" data-hypernova-key="App" data-hypernova-id="....">
   <!-- {"props": ..., "title":"</script "} 

which will throw an error in the JSON.parse method of the payload.

is there a reason closing tags are not encoded here ? Following changes would suffice:

var ENCODE = [
['&', '&amp;'],
['>', '&gt;'],
['<', '&lt;']
];

コントリビューターガイド