-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
154 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
const htmlFile = process.argv[2]; | ||
|
||
console.log(htmlFile + ".clean13465789"); | ||
process.exit(0); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?php | ||
|
||
use Medilies\Xssless\CliInterface; | ||
use Medilies\Xssless\ConfigInterface; | ||
use Medilies\Xssless\Dompurify\DompurifyCliConfig; | ||
use Medilies\Xssless\Xssless; | ||
use Medilies\Xssless\XsslessException; | ||
|
||
it('throws when makeCleaner() with no config', function () { | ||
$cleaner = new Xssless; | ||
|
||
$cleaner->using(new class implements ConfigInterface | ||
{ | ||
public function getClass(): string | ||
{ | ||
return Xssless::class; | ||
} | ||
}); | ||
|
||
expect(fn () => $cleaner->clean('foo'))->toThrow(XsslessException::class); | ||
}); | ||
|
||
it('throws when makeCleaner() with no interface', function () { | ||
$cleaner = new Xssless; | ||
|
||
expect(fn () => $cleaner->clean('foo'))->toThrow(XsslessException::class); | ||
}); | ||
|
||
it('throws when start() with CliInterface', function () { | ||
$cleaner = new Xssless; | ||
$cleaner->using(new DompurifyCliConfig); | ||
|
||
expect(fn () => $cleaner->start())->toThrow(XsslessException::class); | ||
}); | ||
|
||
it('throws when setup() without HasSetupInterface', function () { | ||
$cleaner = new Xssless; | ||
|
||
$cleaner->using(new class implements ConfigInterface | ||
{ | ||
public function getClass(): string | ||
{ | ||
return NoSetupDriver::class; | ||
} | ||
}); | ||
|
||
expect(fn () => $cleaner->setup())->toThrow(XsslessException::class); | ||
}); | ||
|
||
class NoSetupDriver implements CliInterface | ||
{ | ||
public function configure(ConfigInterface $config): static | ||
{ | ||
return $this; | ||
} | ||
|
||
public function exec(string $html): string | ||
{ | ||
return ''; | ||
} | ||
} |