Skip to content

Commit 1f1a59d

Browse files
committed
Rename + split in 2 tests
1 parent 0a14345 commit 1f1a59d

14 files changed

Lines changed: 54 additions & 28 deletions

File tree

docs/guide/building-entity-list.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ The optional `->setWidth()` method accepts either an integer (eg: `20` for 20%),
5454
To hide the column on small screens, use `->hideOnSmallScreens()`.
5555

5656
::: warning
57-
HTML sanitization is enabled by default for list fields (to prevent XSS attacks when displaying the list). You can disable it by using `->shouldSanitizeHtml(false)` field method.
57+
HTML sanitization is enabled by default for list fields (to prevent XSS attacks when displaying the list). You can disable it by using `->setSanitizeHtml(false)` field method.
5858
:::
5959

6060
Sorting columns must be handled in the `getListData()` method, see below.

docs/guide/form-fields/editor.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ Unset the max character count.
9595

9696
Display a character count in the status bar. Default is false.
9797

98-
### `shouldSanitizeHtml(bool $sanitize = true)`
98+
### `setSanitizeHtml(bool $sanitizeHtml = true)`
9999

100100
Toggle HTML sanitization (enabled by default). See [security](#security).
101101

@@ -255,7 +255,7 @@ The [documentation on how to write an Embed class is available here](../form-edi
255255

256256
## Security
257257

258-
Editor content is sanitized by default before storing the data (to prevent XSS attack when displaying HTML content). To disable sanitizing you can call `->shouldSanitizeHtml(false)`.
258+
Editor content is sanitized by default before storing the data (to prevent XSS attack when displaying HTML content). To disable sanitizing you can call `->setSanitizeHtml(false)`.
259259

260260
## Formatter
261261

docs/guide/form-fields/text.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Set a max character count.
3232

3333
Unset the max character count.
3434

35-
### `shouldSanitizeHtml()`
35+
### `setSanitizeHtml()`
3636

3737
Enable HTML sanitization (to prevent XSS attacks if this field data is used as raw HTML).
3838

docs/guide/form-fields/textarea.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Set a max character count.
1616

1717
Unset the max character count.
1818

19-
### `shouldSanitizeHtml()`
19+
### `setSanitizeHtml()`
2020

2121
Enable HTML sanitization (to prevent XSS attacks if this field data is used as raw HTML).
2222

docs/guide/show-fields/text.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ Reset the collapse configuration.
2020

2121
By default, the text is escaped. If you want to display HTML, set this to true.
2222

23-
### `shouldSanitizeHtml(bool $sanitize = true)`
23+
### `setSanitizeHtml(bool $sanitizeHtml = true)`
2424

25-
HTML sanitization is enabled by default for text fields (to prevent XSS attacks when displaying the show). To disable it, call `->shouldSanitizeHtml(false)`.
25+
HTML sanitization is enabled by default for text fields (to prevent XSS attacks when displaying the show). To disable it, call `->setSanitizeHtml(false)`.
2626

2727

2828
### `allowEmbeds(array $embeds)`

src/EntityList/Fields/EntityListField.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class EntityListField implements Arrayable, IsEntityListField, IsSharpFieldWithH
1616
private function __construct(string $key)
1717
{
1818
$this->key = $key;
19-
$this->sanitize = true;
19+
$this->sanitizeHtml = true;
2020
}
2121

2222
public static function make(string $key): self
@@ -55,7 +55,7 @@ public function toArray(): array
5555
'label' => $this->label,
5656
'sortable' => $this->sortable,
5757
'html' => $this->html,
58-
'sanitize' => $this->sanitize,
58+
'sanitize' => $this->sanitizeHtml,
5959
'width' => $this->width,
6060
'hideOnXS' => $this->hideOnXs,
6161
];

src/Form/Fields/SharpFormEditorField.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class SharpFormEditorField extends SharpFormField implements IsSharpFieldWithEmb
6969
protected function __construct(string $key, string $type, ?SharpFieldFormatter $formatter = null)
7070
{
7171
parent::__construct($key, $type, $formatter);
72-
$this->sanitize = true;
72+
$this->sanitizeHtml = true;
7373
}
7474

7575
public static function make(string $key): self

src/Show/Fields/SharpShowTextField.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class SharpShowTextField extends SharpShowField implements IsSharpFieldWithEmbed
2626
protected function __construct(string $key, string $type, ?SharpShowFieldFormatter $formatter = null)
2727
{
2828
parent::__construct($key, $type, $formatter);
29-
$this->sanitize = true;
29+
$this->sanitizeHtml = true;
3030
}
3131

3232
public static function make(string $key): SharpShowTextField
@@ -67,7 +67,7 @@ public function toArray(): array
6767
return parent::buildArray([
6868
'label' => $this->label,
6969
'html' => $this->html,
70-
'sanitize' => $this->sanitize,
70+
'sanitize' => $this->sanitizeHtml,
7171
'collapseToWordCount' => $this->collapseToWordCount,
7272
'localized' => $this->localized,
7373
'embeds' => $this->innerComponentEmbedsConfiguration(false) ?: null,

src/Utils/Sanitization/SharpFieldWithHtmlSanitization.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44

55
trait SharpFieldWithHtmlSanitization
66
{
7-
protected bool $sanitize = false;
7+
protected bool $sanitizeHtml = false;
88

9-
public function shouldSanitizeHtml(bool $sanitize = true): self
9+
public function setSanitizeHtml(bool $sanitizeHtml = true): self
1010
{
11-
$this->sanitize = $sanitize;
11+
$this->sanitizeHtml = $sanitizeHtml;
1212

1313
return $this;
1414
}
@@ -18,6 +18,6 @@ public function shouldSanitizeHtml(bool $sanitize = true): self
1818
*/
1919
public function isSanitizingHtml(): bool
2020
{
21-
return $this->sanitize;
21+
return $this->sanitizeHtml;
2222
}
2323
}

tests/Unit/EntityList/SharpEntityListTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ public function buildList(EntityListFieldsContainer $fields): void
375375
$fields->addField(
376376
EntityListField::make('name')
377377
->setLabel('Name')
378-
->shouldSanitizeHtml(false)
378+
->setSanitizeHtml(false)
379379
->setWidth(.5)
380380
);
381381
}

0 commit comments

Comments
 (0)