Skip to content

Commit 76784d7

Browse files
committed
nfd-status-http-server: inject XSLT polyfill
Refs: #5385 Change-Id: I3595d0d300b02736cacbed525e81e457cf65c9f7
1 parent fe044ce commit 76784d7

3 files changed

Lines changed: 15 additions & 1 deletion

File tree

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,5 @@ NFD contains third-party software, licensed under the following licenses:
6868
* The *WebSocket++* library is licensed under the
6969
[3-clause BSD license](https://github.com/zaphoyd/websocketpp/blob/0.8.1/COPYING)
7070
* The *waf* build system is licensed under the [3-clause BSD license](waf)
71+
* *XSLT Polyfill* is licensed under the
72+
[3-clause BSD license](https://github.com/mfreed7/xslt_polyfill/blob/main/LICENSE)

tools/nfd-status-http-server-files/xslt-polyfill.min.js

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tools/nfd-status-http-server.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env python3
22
"""
3-
Copyright (c) 2014-2024, Regents of the University of California,
3+
Copyright (c) 2014-2026, Regents of the University of California,
44
Arizona Board of Regents,
55
Colorado State University,
66
University Pierre & Marie Curie, Sorbonne University,
@@ -62,6 +62,9 @@ def __serve_report(self):
6262
# (yes, this is a ugly hack)
6363
if (pos := output.find(">") + 1) != 0:
6464
xml = output[:pos] + '<?xml-stylesheet type="text/xsl" href="nfd-status.xsl"?>' + output[pos:]
65+
rootstart = xml.find("<nfdStatus")
66+
if rootstart != -1 and (rootend := xml.find(">", rootstart) + 1) != 0:
67+
xml = xml[:rootend] + '<script src="xslt-polyfill.min.js" xmlns="http://www.w3.org/1999/xhtml"></script>' + xml[rootend:]
6568
self.send_response(200)
6669
self.send_header("Content-Type", "text/xml; charset=UTF-8")
6770
self.end_headers()

0 commit comments

Comments
 (0)