2020-10-30 13:04:26 +00:00
|
|
|
import os
|
|
|
|
import sqlite3
|
|
|
|
|
2020-07-16 14:20:33 +00:00
|
|
|
from .fixtures import *
|
|
|
|
|
2020-08-04 13:42:30 +00:00
|
|
|
def test_title_is_htmlencoded_in_index_html(tmp_path, process, disable_extractors_dict):
|
2020-07-16 14:20:33 +00:00
|
|
|
"""
|
2020-11-23 07:04:39 +00:00
|
|
|
https://github.com/ArchiveBox/ArchiveBox/issues/330
|
2020-07-16 14:20:33 +00:00
|
|
|
Unencoded content should not be rendered as it facilitates xss injections
|
|
|
|
and breaks the layout.
|
|
|
|
"""
|
2020-10-30 13:04:26 +00:00
|
|
|
subprocess.run(['archivebox', 'add', 'http://127.0.0.1:8080/static/title_with_html.com.html'],
|
2020-08-04 13:42:30 +00:00
|
|
|
capture_output=True, env=disable_extractors_dict)
|
2020-10-08 16:02:26 +00:00
|
|
|
list_process = subprocess.run(["archivebox", "list", "--html"], capture_output=True)
|
2020-07-16 14:20:33 +00:00
|
|
|
|
2020-10-30 13:04:26 +00:00
|
|
|
assert "<textarea>" not in list_process.stdout.decode("utf-8")
|
|
|
|
|
|
|
|
def test_title_in_meta_title(tmp_path, process, disable_extractors_dict):
|
|
|
|
add_process = subprocess.run(["archivebox", "add", "http://127.0.0.1:8080/static/title_with_html.com.html"],
|
|
|
|
capture_output=True, env=disable_extractors_dict)
|
|
|
|
|
|
|
|
os.chdir(tmp_path)
|
|
|
|
conn = sqlite3.connect("index.sqlite3")
|
|
|
|
conn.row_factory = sqlite3.Row
|
|
|
|
c = conn.cursor()
|
|
|
|
c.execute("SELECT title from core_snapshot")
|
|
|
|
snapshot = c.fetchone()
|
|
|
|
conn.close()
|
|
|
|
|
|
|
|
assert snapshot[0] == "It All Starts with a Humble <textarea> ◆ 24 ways"
|
|
|
|
|
|
|
|
def test_title_in_meta_og(tmp_path, process, disable_extractors_dict):
|
|
|
|
add_process = subprocess.run(["archivebox", "add", "http://127.0.0.1:8080/static/title_og_with_html.com.html"],
|
|
|
|
capture_output=True, env=disable_extractors_dict)
|
|
|
|
|
|
|
|
os.chdir(tmp_path)
|
|
|
|
conn = sqlite3.connect("index.sqlite3")
|
|
|
|
conn.row_factory = sqlite3.Row
|
|
|
|
c = conn.cursor()
|
|
|
|
c.execute("SELECT title from core_snapshot")
|
|
|
|
snapshot = c.fetchone()
|
|
|
|
conn.close()
|
|
|
|
|
|
|
|
assert snapshot[0] == "It All Starts with a Humble <textarea>"
|
|
|
|
|
|
|
|
def test_title_malformed(tmp_path, process, disable_extractors_dict):
|
|
|
|
add_process = subprocess.run(["archivebox", "add", "http://127.0.0.1:8080/static/malformed.html"],
|
|
|
|
capture_output=True, env=disable_extractors_dict)
|
|
|
|
|
|
|
|
os.chdir(tmp_path)
|
|
|
|
conn = sqlite3.connect("index.sqlite3")
|
|
|
|
conn.row_factory = sqlite3.Row
|
|
|
|
c = conn.cursor()
|
|
|
|
c.execute("SELECT title from core_snapshot")
|
|
|
|
snapshot = c.fetchone()
|
|
|
|
conn.close()
|
|
|
|
|
|
|
|
assert snapshot[0] == "malformed document"
|