Fix MCP occurrence apostrophe escaping
This commit is contained in:
1 parent
85834a0498
commit
8733ce6148
2 files changed
+31
-4
No files matched your search
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
require_once __DIR__ . '/../../modules/market_management/service.php';
|
||||
|
||||
function fail_test(string $message): void
|
||||
{
|
||||
fwrite(STDERR, $message . PHP_EOL);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
function assert_test(bool $condition, string $message): void
|
||||
{
|
||||
if (!$condition) {
|
||||
fail_test($message);
|
||||
}
|
||||
}
|
||||
|
||||
$plainText = "Test 'A' & <B> \"C\"";
|
||||
$sanitized = market_management_sanitize_multiline_html($plainText);
|
||||
assert_test($sanitized === "Test 'A' & <B> \"C\"", 'Plain text must preserve quotes and escape markup characters once');
|
||||
|
||||
$link = '<a href="https://erpnaurua.imhochrain.ch/files.php?path=Marktmanagement%2Fvertrag.pdf">Vertrag</a>';
|
||||
$sanitizedLink = market_management_sanitize_multiline_html($link);
|
||||
assert_test(str_contains($sanitizedLink, 'class="sg-hyperlink"'), 'Allowed links must remain links');
|
||||
assert_test(str_contains($sanitizedLink, 'href="https://erpnaurua.imhochrain.ch/files.php?path=Marktmanagement%2Fvertrag.pdf"'), 'Link href must remain valid');
|
||||
|
||||
fwrite(STDOUT, "market_management_sanitizer_test: OK\n");
|
||||
Reference in new issue
Block a user