Skip to content

Commit

Permalink
toc: support additional html tags in profile
Browse files Browse the repository at this point in the history
  • Loading branch information
mk6i committed Feb 8, 2025
1 parent 393af7d commit 59de6e7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions server/toc/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ func (s OSCARProxy) logAndReturn500(ctx context.Context, w http.ResponseWriter,
// extractProfile extracts the contents of an HTML <BODY>. If there's no HTML
// body, just return the text.
//
// It only returns the following HTML tags: <b> <i> <font> <a> <u> <br>
// It only returns the following HTML tags: <b> <i> <font> <a> <u> <br> <hr> <s> <sub> <sup>
func extractProfile(htmlContent []byte) string {
tokenizer := html.NewTokenizer(bytes.NewReader(htmlContent))
var bodyContent bytes.Buffer
Expand All @@ -350,7 +350,7 @@ func extractProfile(htmlContent []byte) string {
case html.StartTagToken, html.EndTagToken:
token := tokenizer.Token()
switch token.Data {
case "b", "i", "font", "a", "u", "br":
case "b", "i", "font", "a", "u", "br", "hr", "s", "sub", "sup":
bodyContent.WriteString(token.String())
}
case html.TextToken:
Expand Down
4 changes: 2 additions & 2 deletions server/toc/http_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func TestOSCARProxy_NewServeMux(t *testing.T) {
name: "Successfully retrieve HTML profile",
path: "/info?from=me&user=them&cookie=" + cookie,
expectedStatus: http.StatusOK,
expectedBody: `<font lang="0"><a href="aim:GoChat?RoomName=General&amp;Exchange=4">Let's chat</font></a><br><br><font color="#ff0000" lang="0">colorfg</font><font color="#000000"> </font><font back="#00ff00">colorbg</font><font> </font><font size="4">big</font><font size="3"> <b></font><font>bold</b></font><font> <i></font><font>italic</i></font><font> <u></font><font>underline</u></font><font> 8-)</font>`,
expectedBody: `<font lang="0"><a href="aim:GoChat?RoomName=General&amp;Exchange=4">Let's chat</font></a><br><br><font color="#ff0000" lang="0">colorfg</font><font color="#000000"> </font><font back="#00ff00">colorbg</font><font> </font><font size="4">big</font><font size="3"> <b></font><font>bold</b></font><font> <i></font><font>italic</i></font><font> <u></font><font>underline</u></font><font> 8-)</font><hr><s>strike</s><sub>sub</sub><sup>sup</sup>`,
mockParams: mockParams{
locateParams: locateParams{
userInfoQueryParams: userInfoQueryParams{
Expand All @@ -62,7 +62,7 @@ func TestOSCARProxy_NewServeMux(t *testing.T) {
TLVUserInfo: newTestSession("them").TLVUserInfo(),
LocateInfo: wire.TLVRestBlock{
TLVList: wire.TLVList{
wire.NewTLVBE(wire.LocateTLVTagsInfoSigData, `"<HTML><BODY BGCOLOR="#ffffff"><FONT LANG="0"><A HREF="aim:GoChat?RoomName=General&Exchange=4">Let's chat</FONT></A><BR><BR><FONT COLOR="#ff0000" LANG="0">colorfg</FONT><FONT COLOR="#000000"> </FONT><FONT BACK="#00ff00">colorbg</FONT><FONT> </FONT><FONT SIZE=4>big</FONT><FONT SIZE=3> <B></FONT><FONT>bold</B></FONT><FONT> <I></FONT><FONT>italic</I></FONT><FONT> <U></FONT><FONT>underline</U></FONT><FONT> 8-)</FONT></BODY></HTML>"`),
wire.NewTLVBE(wire.LocateTLVTagsInfoSigData, `"<HTML><BODY BGCOLOR="#ffffff"><FONT LANG="0"><A HREF="aim:GoChat?RoomName=General&Exchange=4">Let's chat</FONT></A><BR><BR><FONT COLOR="#ff0000" LANG="0">colorfg</FONT><FONT COLOR="#000000"> </FONT><FONT BACK="#00ff00">colorbg</FONT><FONT> </FONT><FONT SIZE=4>big</FONT><FONT SIZE=3> <B></FONT><FONT>bold</B></FONT><FONT> <I></FONT><FONT>italic</I></FONT><FONT> <U></FONT><FONT>underline</U></FONT><FONT> 8-)</FONT><HR><S>strike</S><SUB>sub</SUB><SUP>sup</SUP></BODY></HTML>"`),
},
},
},
Expand Down

0 comments on commit 59de6e7

Please sign in to comment.