Skip to content

Commit

Permalink
Clientside output purifying (#824)
Browse files Browse the repository at this point in the history
  • Loading branch information
huangdijia authored Jan 7, 2025
1 parent 6c293b7 commit fe86bd5
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/web-tinker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"prettier": "^1.15.3",
"split-grid": "^1.0.9",
"tailwindcss": "^0.7.2",
"vue": "^2.5.7"
"vue": "^2.5.7",
"dompurify": "^3.2.3"
}
}
2 changes: 1 addition & 1 deletion src/web-tinker/public/app.js

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion src/web-tinker/resources/js/components/Tinker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import TinkerInput from './TinkerInput';
import TinkerOutput from './TinkerOutput';
import Split from 'split-grid';
import DOMPurify from 'dompurify';
export default {
components: {
Expand Down Expand Up @@ -56,7 +57,7 @@ export default {
methods: {
handleExecute(output) {
this.output = output;
this.output = DOMPurify.sanitize(output);
},
initSplit() {
Expand Down
2 changes: 1 addition & 1 deletion src/web-tinker/src/Tinker.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,6 @@ protected function cleanOutput(string $output): string
// Remove ANSI color codes
$output = preg_replace('/\e\[[0-9;]*m/', '', $output);

return htmlentities($output);
return trim($output);
}
}

0 comments on commit fe86bd5

Please sign in to comment.