implement configuration loading with json parser, implement some new argument for it.
ship with example json configuration file. add: method to add doctype/html/head/body to document. see examples in todo! with progamm usage
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
- loose
|
||||
- passthrough
|
||||
- [x] profiles in a seperate .py file
|
||||
- Ok you see, I am too lazy to write the stuff which I completed here, so i just italizized it.
|
||||
|
||||
## To implement:
|
||||
|
||||
@@ -27,15 +28,15 @@ NOTE: That things which are in italic text are already implemented!
|
||||
---
|
||||
|
||||
### Expland strict mode:
|
||||
- [ ] Allow these:
|
||||
- html, head, body
|
||||
- title
|
||||
- meta (with restrictions)
|
||||
- link (for css only)
|
||||
- table, tr, td, th
|
||||
- any of crucuial html tags
|
||||
- [ ] restrict metas (allow):
|
||||
- allow only charset, name, content
|
||||
- *[x] Allow these:*
|
||||
- *html, head, body*
|
||||
- *title*
|
||||
- *meta (with restrictions)*
|
||||
- *link (for css only)*
|
||||
- *table, tr, td, th*
|
||||
- *any of crucuial html tags*
|
||||
- [x] *restrict metas (allow):*
|
||||
- *allow only charset, name, content*
|
||||
- [ ] restrict metas (dont allow):
|
||||
- base
|
||||
- meta http-equiv
|
||||
@@ -79,4 +80,124 @@ Lets maybe use bs4 for this, its fitting cause it can decompose HTML. Fixed!
|
||||
|
||||
### Around 30 minutes later:
|
||||
|
||||
This issue is no longer relevant, it is fixed! using bs4.
|
||||
This issue is no longer relevant, it is fixed! using bs4.
|
||||
|
||||
## Development brach additions (overview of functionallity):
|
||||
|
||||
As a example of the functionallity we use a command to call our sanizizer using the strict mode and we specifiy a configuration living in examples/config_example.json:
|
||||
|
||||
```bash
|
||||
cat ~/Documents/INF6B/html/wm/startseite_wm.html | python src/main.py --mode strict > out.html
|
||||
```
|
||||
|
||||
We output to a file called out.html, this is what the stdout of our programm looks like. if we grad stderr we get any debugging information aswell as errors / warnings / info
|
||||
|
||||
### command output:
|
||||
|
||||
```bash
|
||||
(venv) sebastian@kubuntu:~/Documents/sanigi-html$ cat ~/Documents/INF6B/html/wm/startseite_wm.html | python src/main.py --mode strict > out.html
|
||||
[ DEBUG@2026-04-20 12:32:50 ]: called sanitizer! using this as args:
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html lang="en">
|
||||
|
||||
<h1>Die Fußball-Weltmeisterschaft 2026</h1>
|
||||
<p id="h1_under">vom 11. Juni bis 19. Juli 2026 in Kanada, Mexiko und den USA</p>
|
||||
<img height="480" src="images/wmlogo.jpg" width="640"/>
|
||||
<ul>
|
||||
<li>Eröffnungsspiel:
|
||||
<ul>
|
||||
<li>Am 11. Juni 2026 um 21:00 Uhr im Aztekenstadion in Mexiko-Stadt (Mexiko vs. Südafrika)</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>Finale:
|
||||
<ul>
|
||||
<li>Am 19. Juli 2026 im MetLife Stadium in East Rutherford, New Jersey</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>Teilnehmer:
|
||||
<ul>
|
||||
<li>Erste WM mit 48 teilnehmenden Nationen</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>Format:
|
||||
<ul>
|
||||
<li>Insgesamt 104 Spiele in 12 Gruppen</li>
|
||||
<li>Austragung in 16 Stadien in drei Ländern</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>Zeitzonen:
|
||||
<ul>
|
||||
<li>Das Turnier erstreckt sich über vier verschiedene Zeitzonen in Nordamerika</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>Maskottchen:
|
||||
<ul>
|
||||
<li>Maple, Zayu & Clutch</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</html>['html', 'body', 'header', 'main', 'footer', 'section', 'article', 'nav', 'aside', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p', 'pre', 'code', 'blockquote', 'ul', 'ol', 'li', 'dl', 'dt', 'dd', 'br', 'hr', 'a', 'img', 'figure', 'figcaption', 'table', 'thead', 'tbody', 'tfoot', 'tr', 'th', 'td', 'strong', 'em', 'b', 'i', 'u', 'small', 'details', 'summary', 'time']
|
||||
['http', 'https', 'mailto']
|
||||
True
|
||||
```
|
||||
|
||||
This is what the programm outputted to the stdout file (inserted into out.html):
|
||||
|
||||
```html
|
||||
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html>
|
||||
|
||||
<!-- sanigi-html parsed @ 2026-04-20 12:42:08.625481-->
|
||||
<head></head>
|
||||
|
||||
<body>
|
||||
|
||||
|
||||
|
||||
<h1>Die Fußball-Weltmeisterschaft 2026</h1>
|
||||
<p id="h1_under">vom 11. Juni bis 19. Juli 2026 in Kanada, Mexiko und den USA</p>
|
||||
<img height="480" width="640">
|
||||
<ul>
|
||||
<li>Eröffnungsspiel:
|
||||
<ul>
|
||||
<li>Am 11. Juni 2026 um 21:00 Uhr im Aztekenstadion in Mexiko-Stadt (Mexiko vs. Südafrika)</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>Finale:
|
||||
<ul>
|
||||
<li>Am 19. Juli 2026 im MetLife Stadium in East Rutherford, New Jersey</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>Teilnehmer:
|
||||
<ul>
|
||||
<li>Erste WM mit 48 teilnehmenden Nationen</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>Format:
|
||||
<ul>
|
||||
<li>Insgesamt 104 Spiele in 12 Gruppen</li>
|
||||
<li>Austragung in 16 Stadien in drei Ländern</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>Zeitzonen:
|
||||
<ul>
|
||||
<li>Das Turnier erstreckt sich über vier verschiedene Zeitzonen in Nordamerika</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>Maskottchen:
|
||||
<ul>
|
||||
<li>Maple, Zayu & Clutch</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
||||
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user