diff options
| author | eltrac <hi@eltr.ac> | 2026-03-01 15:41:00 +0800 |
|---|---|---|
| committer | eltrac <hi@eltr.ac> | 2026-03-01 15:41:00 +0800 |
| commit | 8ebfd6d840e6b1741265670ea44a103395bd3e12 (patch) | |
| tree | 64fa35731bd259adf58d86f758426d1fe0249587 /src | |
| parent | ecb8c41937ac06ff631f8bc7ca6c3e8176b76654 (diff) | |
fix(webmention): use UrlValidator instead of matching http(s)://
Diffstat (limited to 'src')
| -rw-r--r-- | src/weepinbell/receiver.clj | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/weepinbell/receiver.clj b/src/weepinbell/receiver.clj index 74ec4a9..c641d7b 100644 --- a/src/weepinbell/receiver.clj +++ b/src/weepinbell/receiver.clj @@ -1,11 +1,13 @@ -(ns weepinbell.receiver - (:require [clojure.string :refer [starts-with?]])) +(ns weepinbell.receiver) -(defn validate-url [url] - (or (starts-with? url "http://") - (starts-with? url "https://"))) +(import 'org.apache.commons.validator.UrlValidator) + +(defn valid-http-url? [url] + (let [schemes (into-array String ["http" "https"]) + validator (UrlValidator. schemes)] + (.isValid validator url))) (defn validate-urls [s t] - (and (validate-url s) (validate-url t))) + (and (valid-http-url? s) (valid-http-url? t))) #_(defn validate-source [s]) |
