View Issue Details

IDProjectCategoryView StatusLast Update
0010570TalerWeb site(s)public2025-11-22 22:06
Reporterhga3 Assigned ToChristian Grothoff Resolution deadline
ImplementerReviewer 
Release signed byDeployed by 
VerifierCommunicator 
Data protection authority notification requiredNo  
CSIRT notification requiredNo  
Estimated effort (hours)Actual effort (hours)0 
Fast-trackNo
Work packagenone
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product Versiongit (master) 
Target Version1.2Fixed in Version1.2 
Summary0010570: Site gen failed when parsing news in function cut_text
Descriptionenv "BASEURL=" ./inc/build-site
Traceback (most recent call last):
  File "/home/user/www.taler.net/./inc/build-site", line 27, in <module>
    main()
  File "/home/user/www.taler.net/./inc/build-site", line 24, in main
    x.run()
  File "/home/user/www.taler.net/inc/sitegen/site.py", line 307, in run
    self.run_localized(locale, tr)
  File "/home/user/www.taler.net/inc/sitegen/site.py", line 225, in run_localized
    content = tmpl.render(
              ^^^^^^^^^^^^
  File "/home/user/www.taler.net/.venv/lib/python3.12/site-packages/jinja2/environment.py", line 1295, in render
    self.environment.handle_exception()
  File "/home/user/www.taler.net/.venv/lib/python3.12/site-packages/jinja2/environment.py", line 942, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "/home/user/www.taler.net/template/rss.xml.j2", line 39, in top-level template code
    {{ get_abstract('news/' + newspostitem['page'], 1000) }}
^^^^^^^^^^^^^^^^
  File "/home/user/www.taler.net/inc/sitegen/site.py", line 152, in get_abstract
    return cut_text(root / "template" / (name + ".j2"), length)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/www.taler.net/inc/sitegen/site.py", line 62, in cut_text
    for i in soup.findAll("p")[1]:
             ~~~~~~~~~~~~~~~~~^^^
IndexError: list index out of range
make: *** [Makefile:11: site] Error 1
TagsNo tags attached.

Required notifications

Address or linkRemarkAdded byNotifiedActions

Activities

hga3

2025-11-09 22:24

reporter   ~0026352

Resolved with attached patch. The patch is applied and, after successful local testing, pushed to upstream onto "c76de6d942874529eaba97bc3d065863bf1b27d1" of git://git.gnunet.org/www_shared.git.
sitegen.site.py.patch (1,248 bytes)   
diff --git a/sitegen/site.py b/sitegen/site.py
index b7fbf6b..4aaddd3 100644
--- a/sitegen/site.py
+++ b/sitegen/site.py
@@ -58,13 +58,25 @@ def cut_text(filename, count):
         soup = BeautifulSoup(html, features="lxml")
         for script in soup(["script", "style"]):
             script.extract()
-        k = []
-        for i in soup.findAll("p")[1]:
-            k.append(i)
-        b = "".join(str(e) for e in k)
-        text = html2text(b.replace("\n", " "))
-        textreduced = (text[:count] + " [...]") if len(text) > count else (text)
-        return textreduced
+        paragraphs = soup.find_all("p")
+
+        # No <p> tags at all → return empty string
+        if not paragraphs:
+            return ""
+
+        # If only one <p>, use that one; otherwise use the second
+        target = paragraphs[1] if len(paragraphs) > 1 else paragraphs[0]
+
+        # Convert contents of the <p> to HTML string
+        b = "".join(str(e) for e in target.contents)
+
+        # Convert to text
+        text = html2text(b.replace("\n", " ")).strip()
+
+        # Truncate
+        if len(text) > count:
+            return text[:count] + " [...]"
+        return text
 
 
 def extract_body(text, content_id="newspost-content"):
sitegen.site.py.patch (1,248 bytes)   

hga3

2025-11-10 11:01

reporter   ~0026356

Hi Christian,
I have no permissions to close issues. Please review and close, THX. It's resolved by upstream commit (8e51037a)

hga3

2025-11-10 11:02

reporter   ~0026357

Hi Christian,
I have no permissions to close issues. Please review and close, THX. It's resolved by upstream commit (8e51037a)

Issue History

Date ModifiedUsernameFieldChange
2025-11-09 22:19hga3New Issue
2025-11-09 22:19hga3Statusnew => assigned
2025-11-09 22:19hga3Assigned To => hga3
2025-11-09 22:24hga3Note Added: 0026352
2025-11-09 22:24hga3File Added: sitegen.site.py.patch
2025-11-10 11:01hga3Note Added: 0026356
2025-11-10 11:02hga3Assigned Tohga3 => Christian Grothoff
2025-11-10 11:02hga3Statusassigned => feedback
2025-11-10 11:02hga3Note Added: 0026357
2025-11-10 15:09Christian GrothoffStatusfeedback => informing
2025-11-10 15:09Christian GrothoffResolutionopen => fixed
2025-11-10 15:09Christian GrothoffFixed in Version => 1.2
2025-11-10 15:09Christian GrothoffTarget Version => 1.2
2025-11-22 22:06Christian GrothoffStatusinforming => closed