alvarcarto / alvarcarto/url-to-pdf-api

'#' in data URI body might break the PDF

Ouverte
#90 1 commentaire 1 réaction 0 personnes assignées Voir sur GitHub
bug PR welcome
Langage dominant
HTML
Étoiles
7.1k
Forks
779
Métriques de merge des PR
Aucune PR mergée en 30 j

Description

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.

Guide de contribution

Aucun guide de contribution indexé pour ce dépôt

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.