Downloading the latest DOMPurify release and adding it to sites/all/libraries results in the required library having the path "sites/all/libraries/DOMPurify/dist/purify.min.js". This results in colorbox_requirements() not being able to find it.

Comments

DamienMcKenna created an issue. See original summary.

damienmckenna’s picture

Title: DOMPurify library » DOMPurify library path
damienmckenna’s picture

Status: Active » Needs review
StatusFileSize
new925 bytes

This changes the paths in hook_libraries() so that they match what the library provides.

Status: Needs review » Needs work

The last submitted patch, 3: colorbox-n3275787-3.patch, failed testing. View results

camuschino_x’s picture

It works for me. Thanks

kevin morse’s picture

Also worked for me.

pixiekat’s picture

If you're installing from composer or asset-packagist, you'll need to change the directory name from "dompurify" to "DOMPurify", too.

terminator727’s picture

how i can install the DOMPurify librarie with composer?

pixiekat’s picture

Add this to your repositories object, changing dist and version to whatever the current version that you want is:

    "repositories": [
        {
            "type": "composer",
            "url": "https://packages.drupal.org/7"
        },
        {
            "type": "composer",
            "url": "https://asset-packagist.org"
        },
        ....
        {
            "type": "package",
            "package": {
                "name": "cure53/dompurify",
                "version": "2.3.6",
                "type": "drupal-library",
                "dist": {
                    "url": "https://github.com/cure53/DOMPurify/archive/refs/tags/2.3.6.zip",
                    "type": "zip"
                }
            }
        }
    ],

Then run composer require cure53/dompurify

krzysztof domański’s picture

Status: Needs work » Reviewed & tested by the community

#3 LGTM

bcobin’s picture

I have the same issue in Drupal 9, but the code here doesn't seem to correspond. And I don't see the same issue tagged for Drupal 9. The library is installed in /libraries/DOMPurify/dist/purify.min.js, as per instructions.

Any ideas? Thanks in advance...

softpol’s picture

Same problem here (Drupal-9.4.8): colorbox doesn't see the DOMPurify library.

ls -l libraries/DOMPurify/dist
total 696
-rw-r--r-- 1 61671 Oct 10 13:07 purify.cjs.js
-rw-r--r-- 1 119310 Oct 10 13:07 purify.cjs.js.map
-rw-r--r-- 1 61660 Oct 10 13:07 purify.es.js
-rw-r--r-- 1 119307 Oct 10 13:07 purify.es.js.map
-rw-r--r-- 1 64590 Oct 10 13:07 purify.js
-rw-r--r-- 1 119314 Oct 10 13:07 purify.js.map
-rw-r--r-- 1 21689 Oct 10 13:07 purify.min.js
-rw-r--r-- 1 88946 Oct 10 13:07 purify.min.js.map

ls -l libraries/DOMPurify/
total 4
drwxr-xr-x 2 4096 Oct 10 13:07 dist

ls -l libraries
total 80
drwxr-xr-x 3 4096 Oct 10 13:07 DOMPurify
(…)

bcobin’s picture

If I remember correctly, installing from Drush (as noted on the project page) did it for me:

If you are using the DOMPurify library, you can use drush colorbox:dompurify to install the library. It looks for the library in libraries/DOMPurify/dist/purify.min.js.

Good luck!

softpol’s picture

Indeed, this works!

But the drush command installs the library in libraries/dompurify instead of in libraries/DOMPurify.
So, the instructions on the colorbox settings page are wrong…

paulmckibben’s picture

Folks, since this issue was originally against the Drupal 7 version of colorbox, and since that specific issue is not yet resolved, it would be helpful to track Drupal 9 concerns in a separate issue.

I have created #3314730: DOMPurify library path - inconsistent capitalization to track the potential Drupal 9 issue with the DOMPurify library path. I will look more deeply as time allows, but anyone is welcome to offer a deeper analysis and a patch (and I would be eternally grateful).

damienmckenna’s picture

clayclai’s picture

I was able to make the warning go away by creating a symbolic link one level up:

drupal7/sites/all/libraries/DOMPurify# ln -sf dist/purify.min.js purify.min.js

I wasn't sure if it needed and couldn't find the map file, so I added:

drupal7/sites/all/libraries/DOMPurify# ln -sf dist/purify.min.js.map purify.min.js.map

for good measure. Hope this helps.

bosmaen’s picture

Solution #17 works for D7. Good one clayclai

Kohaydo’s picture

path "sites/all/libraries/DOMPurify/dist/purify.min.js"
change Folder name - "DOMPurify' to "dompurify"

aiphes’s picture

Issue here on D9.5.7 and Media Colorbox (colorbox) Enabled 2.0.0

The DOMPurify library is not installed. The Colorbox module uses this library to sanitize HTML captions. Without this library, all captions will be treated as plain text. If you intend to have HTML captions in Colorbox content, download the DOMPurify library, extract it, and copy the dist directory into the /libraries/DOMPurify folder in your Drupal installation directory. Specifically, the system looks for /libraries/DOMPurify/dist/purify.min.js.

with this:

ibraries/DOMPurify$ ls -la dist/
total 668
drwxrwxr-x 2 provence-formation-php7 provence-formation-php7    216 Mar 23 20:40 .
drwxrwxr-x 3 provence-formation-php7 provence-formation-php7     26 Mar 28 15:03 ..
-rw-rw-r-- 1 provence-formation-php7 provence-formation-php7  64456 Mar 23 20:40 purify.cjs.js
-rw-rw-r-- 1 provence-formation-php7 provence-formation-php7 120024 Mar 23 20:40 purify.cjs.js.map
-rw-rw-r-- 1 provence-formation-php7 provence-formation-php7  64445 Mar 23 20:40 purify.es.js
-rw-rw-r-- 1 provence-formation-php7 provence-formation-php7 120021 Mar 23 20:40 purify.es.js.map
-rw-rw-r-- 1 provence-formation-php7 provence-formation-php7  67531 Mar 23 20:40 purify.js
-rw-rw-r-- 1 provence-formation-php7 provence-formation-php7 120028 Mar 23 20:40 purify.js.map
-rw-rw-r-- 1 provence-formation-php7 provence-formation-php7  22938 Mar 23 20:40 purify.min.js
-rw-rw-r-- 1 provence-formation-php7 provence-formation-php7  89510 Mar 23 20:40 purify.min.js.map
mj42’s picture

D7.95 path that solved it for me was "/sites/all/libraries/DOMPurify/purify.min.js" (Colorbox 7.x-2.17)

k8e1050’s picture

Thanks mj42. That worked for me as well. woohoo.

paulmckibben’s picture

Status: Reviewed & tested by the community » Closed (works as designed)

For security reasons, you should not install the entire contents of the DOMPurify archive. You should only install purify.min.js, in sites/all/libraries/DOMPurify/purify.min.js.

damienmckenna’s picture

StatusFileSize
new1.35 KB

Paul: then the codebase needs to be updated to streamline this. The codebase includes a segment in the Drush Make file for downloading Colorbox, it should have a similar section for downloading DOMPurify and then hook_libraries() should match where it stores the files.

Would this work?

paulmckibben’s picture

Status: Closed (works as designed) » Needs work

Damien, thanks for clarifying that the issue has to do with automatically downloading the file using drush make. That was not clear from the issue description or comment history.

I'm doing my best to support the Drupal 7 version on a best effort basis, so I may need further help. I see that we need to support a download mechanism using drush make. However, I'd also like to avoid hard-coding a version number if possible. Is there a way we can do that?

damienmckenna’s picture

How about pointing to the 3.x version, rather than a release version? https://github.com/cure53/DOMPurify/blob/3.x/dist/purify.min.js

I can also look at the docs to see if the wording can be improved to make it easier for people to do it correctly.

paulmckibben’s picture

@DamienMcKenna, yes, 3.x would be fine. And I also appreciate your eyes on the documentation. Thank you.

damienmckenna’s picture

Assigned: Unassigned » damienmckenna

Adding it to my list to work on.

damienmckenna’s picture

Status: Needs work » Needs review
StatusFileSize
new2.36 KB

How about something like this?

damienmckenna’s picture

Assigned: damienmckenna » Unassigned
chowdah’s picture

Ran into this on a Drupal 7 that I have yet to upgrade. I'll be migrating to D9 for this site very soon. What worked for this install was keeping the folder name DOMPurify, then moving the purify.min.js & purify.min.js.map from the dist folder to the root of the DOMPurify folder and deleted all the other files. #17 would have worked as well, but im trying to minimize and clean up all the crap from this site [it's a beast that's been migrated from D5 to D6 to d7] prior to upgrade.

dqd’s picture

Version: 7.x-2.x-dev » 2.0.x-dev
Status: Needs review » Needs work

Well, this is also true for latest v2 release and 2.0-dev - so a re-roll would be great and some maintainers to at least merge to dev would be very appreciated ;-)

or! -> to simply change documentation on this.

damienmckenna’s picture

Version: 2.0.x-dev » 7.x-2.x-dev
Status: Needs work » Needs review

Because they use completely different methods for managing the codebases, please keep the D7 and D9+ changes separate.

coolwaveTC’s picture

Post #9 worked for me, Jan 2024. Drupal 10 site on Pantheon.

dqd’s picture

Because they use completely different methods for managing the codebases, please keep the D7 and D9+ changes separate.

I see! That makes sense! Thanks for clarifying @DamienMcKenna and sorry for the noise.

Post #9 worked for me, Jan 2024. Drupal 10 site on Pantheon.

Interesting! Can you please create a new issue like Damien suggested before, so that a patch can be created there based on #9 for this version? Thanks for your report! +1

wildhostile’s picture

Post #14 is the key on Drupal 9.5.11. Thanks @softpol.

  • paulmckibben committed 2f1bae20 on 7.x-2.x
    Issue #3275787 by DamienMcKenna, paulmckibben: DOMPurify library path
    
paulmckibben’s picture

Status: Needs review » Fixed

@DamienMcKenna, thanks for the patch, and sorry for the long wait. I have committed your patch to the 7.x-2.x branch.

theturtle’s picture

Hi,

I'm working with a Drupal 7, Colorbox 2.17 en DOMPurify, everyhting was fine.

Yesterday, I updated Colorbox from 2.17 to 2.18 and since that, I have a problem with the DOMPurify's library which is not found.

I put the file at sites/all/libraries/DOMPurify/purify.min.js, with 2.17 everything is fine, with 2.18, library isn't detected.

Do you have any explanations ?

Thanks.

paulmckibben’s picture

Status: Fixed » Needs work

@theturtle Thanks for reporting this. The patch from #29 removed the version information from the library info, which caused the version check to fail. I will add that back and provide a new release shortly.

  • paulmckibben committed 87085c65 on 7.x-2.x
    Issue #3275787 by DamienMcKenna, paulmckibben, theturtle: DOMPurify...
paulmckibben’s picture

Status: Needs work » Fixed

This is now committed, and I'll tag a new release 7.x-2.19 shortly.

theturtle’s picture

Hi Paul,

This is perfect! It works perfectly with the 2.19 version.

Thanks for the quick response and all your work.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

walmac’s picture

#31 worked for me (Drupal 7.99).

ccarnnia’s picture

hi all,
mv libraries/DOMPurify libraries/dompurify
fixed it for me.