Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Safe Mode Set from Environment Variable #88

Merged
merged 1 commit into from
May 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ services:
- SHOW_TOC=false
- HOME_FILE=README
- FONT_SIZE=15
- HTML_SAFE_MODE=true
volumes:
- ./perlite/Demo:/var/www/perlite/Demo:ro

Expand Down
3 changes: 3 additions & 0 deletions perlite/Demo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,7 @@ If you want to discuss about Perlite you can join the thread in the [Obsidian Fo
[Wiki](https://en.wikipedia.org/wiki/Perlite):
*Perlite is an amorphous volcanic glass ... typically formed by the hydration of obsidian.*

## Safe Mode Test
You should be very cautious about disabling safe mode. If safe mode is **OFF** the following text will be red, if safe mode is **ON** you should see unrendered HTML below.

<div style="text-align: center; color: red;">Red if Unsafe</div>
3 changes: 2 additions & 1 deletion perlite/content.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,12 @@ function parseContent($requestFile) {
global $startDir;
global $lineBreaks;
global $allowedFileLinkTypes;
global $htmlSafeMode;


//$Parsedown = new ParsedownExtra();
$Parsedown = new PerliteParsedown();
$Parsedown->setSafeMode(true);
$Parsedown->setSafeMode($htmlSafeMode);
$Parsedown->setBreaksEnabled($lineBreaks);
$cleanFile = '';

Expand Down
8 changes: 8 additions & 0 deletions perlite/helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,14 @@
$font_size = "15";
}

// Set safe mode from environment variable
$htmlSafeMode = getenv('HTML_SAFE_MODE');
if (empty($htmlSafeMode)) {
$htmlSafeMode = true;
} else {
$htmlSafeMode = filter_var($htmlSafeMode, FILTER_VALIDATE_BOOLEAN);
}


$about = '.about';

Expand Down