renatomarinho / laravel-page-speed

Package to optimize your site automatically which results in a 35%+ optimization
MIT License
2.4k stars 275 forks source link

Allow forward slashes inside integrity attribute #155

Open frizikk opened 3 years ago

frizikk commented 3 years ago

Description

Some CDN's generate sri hash where may contain //

Motivation and context

RemoveComments class works incorrectly

Given string

<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/js/bootstrap.min.js" integrity="sha384-+YQ4JLhjyBLPDQt//I+STsc9iw4uQqACwlvpslubQzn4u2UU2UFM80nGisd026JF" crossorigin="anonymous"></script>

Without fix RemoveComments class return

<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/js/bootstrap.min.js" integrity="sha384-+YQ4JLhjyBLPDQt

How has this been tested?

composer test

Types of changes

What types of changes does your code introduce? Put an x in all the boxes that apply:

Checklist:

c-benoit commented 2 years ago

Hi, i've this problem ; and your solution dont work either for this one <script rel="preload" src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/js/bootstrap.bundle.min.js" integrity="sha384-gtEjrD/SeCtmISkJkNUaaKMoLD0//ElJ19smozuHV6z3Iehds+3Ulb9Bn9Plx0x4" crossorigin="anonymous"></script> `Error parsing 'integrity' attribute ('sha384-gtEjrD/SeCtmISkJkNUaaKMoLD0

<script src='). The hash algorithm must be one of 'sha256', 'sha384', or 'sha512', followed by a '-' character.`