some pleroma frontends apparently use notice urls

This commit is contained in:
Ted Unangst 2023-03-09 00:54:59 -05:00
parent bf9e65d699
commit b261f73c49
2 changed files with 5 additions and 5 deletions

View File

@ -511,7 +511,8 @@ var re_mast0link = regexp.MustCompile(`https://[[:alnum:].]+/users/[[:alnum:]]+/
var re_masto1ink = regexp.MustCompile(`https://[[:alnum:].]+/@[[:alnum:]]+/[[:digit:]]+`) var re_masto1ink = regexp.MustCompile(`https://[[:alnum:].]+/@[[:alnum:]]+/[[:digit:]]+`)
var re_misslink = regexp.MustCompile(`https://[[:alnum:].]+/notes/[[:alnum:]]+`) var re_misslink = regexp.MustCompile(`https://[[:alnum:].]+/notes/[[:alnum:]]+`)
var re_honklink = regexp.MustCompile(`https://[[:alnum:].]+/u/[[:alnum:]]+/h/[[:alnum:]]+`) var re_honklink = regexp.MustCompile(`https://[[:alnum:].]+/u/[[:alnum:]]+/h/[[:alnum:]]+`)
var re_romalink = regexp.MustCompile(`https://[[:alnum:].]+/objects/[[:alnum:]-]+`) var re_r0malink = regexp.MustCompile(`https://[[:alnum:].]+/objects/[[:alnum:]-]+`)
var re_roma1ink = regexp.MustCompile(`https://[[:alnum:].]+/notice/[[:alnum:]]+`)
var re_qtlinks = regexp.MustCompile(`>https://[^\s<]+<`) var re_qtlinks = regexp.MustCompile(`>https://[^\s<]+<`)
func qutify(user *WhatAbout, content string) string { func qutify(user *WhatAbout, content string) string {
@ -521,11 +522,10 @@ func qutify(user *WhatAbout, content string) string {
mlinks := re_qtlinks.FindAllString(malcontent, -1) mlinks := re_qtlinks.FindAllString(malcontent, -1)
for _, m := range mlinks { for _, m := range mlinks {
m = m[1 : len(m)-1] m = m[1 : len(m)-1]
if re_mast0link.MatchString(m) || if re_mast0link.MatchString(m) || re_masto1ink.MatchString(m) ||
re_masto1ink.MatchString(m) ||
re_misslink.MatchString(m) || re_misslink.MatchString(m) ||
re_honklink.MatchString(m) || re_honklink.MatchString(m) ||
re_romalink.MatchString(m) { re_r0malink.MatchString(m) || re_roma1ink.MatchString(m) {
j, err := GetJunk(user.ID, m) j, err := GetJunk(user.ID, m)
if err == nil { if err == nil {
q, ok := j.GetString("content") q, ok := j.GetString("content")

2
web.go
View File

@ -2113,7 +2113,7 @@ func somedays() string {
} }
func lookatme(ava string) string { func lookatme(ava string) string {
if strings.Contains(ava, serverName + "/" + userSep) { if strings.Contains(ava, serverName+"/"+userSep) {
idx := strings.LastIndexByte(ava, '/') idx := strings.LastIndexByte(ava, '/')
if idx < len(ava) { if idx < len(ava) {
name := ava[idx+1:] name := ava[idx+1:]