trac-code-comments-plugin
trac-code-comments-plugin copied to clipboard
Fix subscription module accessing an invalid URL for REST-API
The subscription REST-API lives under /subscription. However the code tried accessing /undefined/subscriptionundefined.
2023-08-27 14:05:51,762 Trac[main] WARNING: [172.17.0.1]
HTTPNotFound: 404 Trac Error (No node undefined/subscriptionundefined),
<RequestWithSession "GET '/browser/undefined/subscriptionundefined'">,
referrer 'http://127.0.0.1:30443/browser/SomeRepo'
The reason is that the base URL is supposed to be encoded in the HTML attribute data-base-url and the path in data-path. These attribute names can not be used in Python as argument because they contain dashes. So in Python the dashes are replaced by underscores. genshi.builder.tag converts the underscores back to dashes and therefore generates the required attribute names. Its supposed replacement trac.util.html.html (which was enabled in fa7cdff4500f3a2a215645d3cd5470833dfca624) does not perform such a conversion thereby generating the wrong HTML attributes leading to the wrong URL in the request.
For the upcoming migration away from Genshi we could consider using the already present CodeComments dictionary. It already contains a "path" element, although with a somewhat different content.