alvarcarto / alvarcarto/url-to-pdf-api
'#' in data URI body might break the PDF
- 主要语言
- HTML
- 星标
- 7.1k
- 派生
- 779
- PR 合并指标
- 30 天内没有已合并 PR
描述
First, thanks for the awesome repo! We've cherry-picked on it quite extensively [@TimmaLabs](https://github.com/TimmaLabs).
Over the New Year we came upon an issue (which other users might now be running into as well) where our PDFs would suddenly start breaking after a deploy. Then we ran into this in the logs:
```
2019-01-01T14:31:05.502Z - info: [render-core.js] PAGE LOG:
_type=warning, _text=Using unescaped '#' characters in a data URI body is deprecated
and will be removed in M71, around December 2018. Please use '%23' instead.
See https://www.chromestatus.com/features/5656049583390720 for more details., _args=[]
```
A simple fix was to escape all `#` characters before appending the HTML to the data URI (in [render-core.js:90](https://github.com/alvarcarto/url-to-pdf-api/blob/ebc822ffb4b2550ff2f24ba024a4945209375a92/src/core/render-core.js#L90)):
```diff
logger.info('Set HTML ..');
+ // https://www.chromestatus.com/features/5656049583390720
+ opts.html = opts.html.replace(/#/g, '%23');
// https://github.com/GoogleChrome/puppeteer/issues/
await page.goto(`data:text/html;charset=UTF-8,${opts.html}`, opts.goto);
```
Didn't want to PR this change yet as I'm not sure whether this is a common issue or not.
贡献指南
这个仓库没有索引到贡献指南
评估
这个 Issue 还没有评估数据。