Notify link=: a stage's public/ file sets the phone tap target
A stage's notify block may name `link=<pattern>` (validated like `open=`). When the hook fires, the newest public/ match is read (at most 4 KiB); its first non-empty line, if an absolute http(s) URL ntfy accepts as a click, becomes the ntfy Click and the app notification click, with the run kept as the app's run action and ntfy's browser view. A missing file or invalid URL keeps today's tap target and is noted on the receipt diagnostic. Android opens such an http(s) click in the browser (after clearing the notification) instead of handing it to Flutter as a route.
This commit is contained in:
@@ -115,7 +115,7 @@ func PublishNtfy(ctx context.Context, destination, title, summary, filename stri
|
||||
if !destinationName.MatchString(destination) || strings.TrimSpace(title) == "" || strings.TrimSpace(summary) == "" || len(title) > 256 || len(summary) > 2048 || !utf8.ValidString(title) || !utf8.ValidString(summary) || strings.ContainsAny(title+summary, "\r\n\x00") {
|
||||
return nil, fmt.Errorf("invalid ntfy notification metadata")
|
||||
}
|
||||
if !validNtfyClick(click) {
|
||||
if !ValidNtfyClick(click) {
|
||||
return nil, fmt.Errorf("invalid ntfy click action")
|
||||
}
|
||||
actions, err := ntfyViewActions(views)
|
||||
@@ -227,11 +227,11 @@ func PublishNtfy(ctx context.Context, destination, title, summary, filename stri
|
||||
return Values{"destination": destination, "message_id": ack.ID, "attachment_url": ack.Attachment.URL, "filename": filename}, nil
|
||||
}
|
||||
|
||||
// validNtfyClick accepts an empty click or an absolute URL the ntfy server will
|
||||
// ValidNtfyClick accepts an empty click or an absolute URL the ntfy server will
|
||||
// hand to the operating system on tap: a scheme, no credentials, no fragment,
|
||||
// no control characters and a bounded length. The value is an operator-visible
|
||||
// deep link, never a place to smuggle a token.
|
||||
func validNtfyClick(click string) bool {
|
||||
func ValidNtfyClick(click string) bool {
|
||||
if click == "" {
|
||||
return true
|
||||
}
|
||||
@@ -262,7 +262,7 @@ func ntfyViewActions(views []NtfyView) (string, error) {
|
||||
if label == "" || len(label) > 64 || strings.ContainsAny(label, ",;\"'\\=") || !printableASCII(label) {
|
||||
return "", fmt.Errorf("invalid ntfy action label")
|
||||
}
|
||||
if view.URL == "" || !validNtfyClick(view.URL) || strings.ContainsAny(view.URL, ",;\"'\\") || !printableASCII(view.URL) {
|
||||
if view.URL == "" || !ValidNtfyClick(view.URL) || strings.ContainsAny(view.URL, ",;\"'\\") || !printableASCII(view.URL) {
|
||||
return "", fmt.Errorf("invalid ntfy action URL")
|
||||
}
|
||||
if u, err := url.Parse(view.URL); err != nil || (u.Scheme != "http" && u.Scheme != "https") || u.Hostname() == "" {
|
||||
|
||||
Reference in New Issue
Block a user