diff options
author | Lars Ingebrigtsen <larsi@gnus.org> | 2022-01-18 11:53:01 +0100 |
---|---|---|
committer | Lars Ingebrigtsen <larsi@gnus.org> | 2022-01-18 11:53:09 +0100 |
commit | 9f25c41ad45eaa34c8b7aa88a8c75d5dd4bd7ba7 (patch) | |
tree | 1bc08689be22a348b13b2f58380eb6bacfff758a /admin/unidata/unidata-gen.el | |
parent | 702ce8dc3e3cde378feed566b7ed9032d05f611b (diff) | |
download | emacs-9f25c41ad45eaa34c8b7aa88a8c75d5dd4bd7ba7.tar.gz |
Add textsec-domain-suspicious-p
* .gitignore: Ignore idna-mapping.el.
* admin/notes/unicode: Note idna-mapping file.
* admin/unidata/IdnaMappingTable.txt: New file.
* admin/unidata/Makefile.in (all): Generate idna-mapping.el.
* admin/unidata/unidata-gen.el (unidata-gen-idna-mapping): Generate.
* lisp/international/textsec.el (textsec-domain-suspicious-p): New
function.
Diffstat (limited to 'admin/unidata/unidata-gen.el')
-rw-r--r-- | admin/unidata/unidata-gen.el | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/admin/unidata/unidata-gen.el b/admin/unidata/unidata-gen.el index 1076f977236..ad72eed9955 100644 --- a/admin/unidata/unidata-gen.el +++ b/admin/unidata/unidata-gen.el @@ -1602,6 +1602,46 @@ Property value is a symbol `o' (Open), `c' (Close), or `n' (None)." (insert ")") (unidata-gen-charprop file (buffer-string))))) +(defun unidata-gen-idna-mapping (&optional file) + ;; Running from Makefile. + (unless file + (setq file (pop command-line-args-left))) + (let ((map (make-char-table nil))) + (with-temp-buffer + (unidata-gen--insert-file "IdnaMappingTable.txt") + (while (re-search-forward "^\\([0-9A-F]+\\)\\(?:\\.\\.\\([0-9A-F]+\\)\\)? +; +\\([^ ]+\\) +\\(?:; +\\([ 0-9A-F]+\\)\\)?" + nil t) + (let ((start (match-string 1)) + (end (match-string 2)) + (status (match-string 3)) + (mapped (match-string 4))) + ;; Make reading the file slightly faster by using `t' + ;; instead of `disallowed' all over the place. + (when (string-match-p "\\`disallowed" status) + (setq status "t")) + (unless (or (equal status "valid") + (equal status "deviation")) + (set-char-table-range + map + (if end + (cons (string-to-number start 16) + (string-to-number end 16)) + (string-to-number start 16)) + (cond + ((equal status "mapped") + (apply #'string + (mapcar (lambda (char) + (string-to-number char 16)) + (split-string (string-trim mapped))))) + (t + (intern status)))))))) + (with-temp-buffer + (insert "(defconst idna-mapping-table\n") + (let ((print-length nil)) + (prin1 map (current-buffer))) + (insert ")") + (unidata-gen-charprop file (buffer-string))))) + ;;; unidata-gen.el ends here |