From ac9b7de2951493121c608c68ab21ddf2aca1bd69 Mon Sep 17 00:00:00 2001 From: Ralph Slooten Date: Tue, 4 Mar 2025 16:51:19 +1300 Subject: [PATCH 1/6] Fix: Allow searching messages using only Cyrillic characters (#450) --- internal/storage/search.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/storage/search.go b/internal/storage/search.go index 6213769..0d1554a 100644 --- a/internal/storage/search.go +++ b/internal/storage/search.go @@ -265,8 +265,8 @@ func searchQueryBuilder(searchString, timezone string) *sqlf.Stmt { lw = lw[1:] } - re := regexp.MustCompile(`[a-zA-Z0-9]+`) - if !re.MatchString(w) { + // ignore blank searches + if len(w) == 0 { continue } From 9a1f3a6bb5d40e739e0606ae4297165670cda856 Mon Sep 17 00:00:00 2001 From: Ralph Slooten Date: Wed, 5 Mar 2025 17:14:06 +1300 Subject: [PATCH 2/6] Chore: Replace PrismJS with highlight.js for HTML syntax highlighting --- package-lock.json | 17 +++- package.json | 2 +- server/ui-src/assets/styles.scss | 102 ++----------------- server/ui-src/components/message/Message.vue | 13 +-- 4 files changed, 32 insertions(+), 102 deletions(-) diff --git a/package-lock.json b/package-lock.json index 958084d..d90ab92 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,10 +15,10 @@ "color-hash": "^2.0.2", "dayjs": "^1.11.10", "dompurify": "^3.1.6", + "highlight.js": "^11.11.1", "ical.js": "^2.0.1", "mitt": "^3.0.1", "modern-screenshot": "^4.4.30", - "prismjs": "^1.29.0", "rapidoc": "^9.3.4", "timezones-list": "^3.0.3", "vue": "^3.2.13", @@ -1823,9 +1823,9 @@ "license": "MIT" }, "node_modules/core-js-pure": { - "version": "3.40.0", - "resolved": "https://registry.npmjs.org/core-js-pure/-/core-js-pure-3.40.0.tgz", - "integrity": "sha512-AtDzVIgRrmRKQai62yuSIN5vNiQjcJakJb4fbhVw3ehxx7Lohphvw9SGNWKhLFqSxC4ilD0g/L1huAYFQU3Q6A==", + "version": "3.41.0", + "resolved": "https://registry.npmjs.org/core-js-pure/-/core-js-pure-3.41.0.tgz", + "integrity": "sha512-71Gzp96T9YPk63aUvE5Q5qP+DryB4ZloUZPSOebGM88VNw8VNfvdA7z6kGA8iGOTEzAomsRidp4jXSmUIJsL+Q==", "hasInstallScript": true, "license": "MIT", "funding": { @@ -2213,6 +2213,15 @@ "node": ">= 0.4" } }, + "node_modules/highlight.js": { + "version": "11.11.1", + "resolved": "https://registry.npmjs.org/highlight.js/-/highlight.js-11.11.1.tgz", + "integrity": "sha512-Xwwo44whKBVCYoliBQwaPvtd/2tYFkRQtXDWj1nackaV2JPXx3L0+Jvd8/qCJ2p+ML0/XVkJ2q+Mr+UVdpJK5w==", + "license": "BSD-3-Clause", + "engines": { + "node": ">=12.0.0" + } + }, "node_modules/ical.js": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/ical.js/-/ical.js-2.1.0.tgz", diff --git a/package.json b/package.json index 6fe4e10..680ca19 100644 --- a/package.json +++ b/package.json @@ -16,10 +16,10 @@ "color-hash": "^2.0.2", "dayjs": "^1.11.10", "dompurify": "^3.1.6", + "highlight.js": "^11.11.1", "ical.js": "^2.0.1", "mitt": "^3.0.1", "modern-screenshot": "^4.4.30", - "prismjs": "^1.29.0", "rapidoc": "^9.3.4", "timezones-list": "^3.0.3", "vue": "^3.2.13", diff --git a/server/ui-src/assets/styles.scss b/server/ui-src/assets/styles.scss index d04ff3c..0688ed7 100644 --- a/server/ui-src/assets/styles.scss +++ b/server/ui-src/assets/styles.scss @@ -354,12 +354,19 @@ body.blur { } } -/* PrismJS 1.29.0 - modified! -https://prismjs.com/download.html#themes=prism-coy&languages=markup+css */ +// HighlightJS for HTML rendering +@import "highlight.js/styles/github.css"; + +@include color-mode(dark) { + @import "highlight.js/scss/github-dark"; + + .hljs { + background: transparent; + } +} + code[class*="language-"], pre[class*="language-"] { - // color: #000; - // background: 0 0; font-size: 0.85em; text-align: left; white-space: pre; @@ -408,72 +415,6 @@ pre[class*="language-"] { white-space: normal; } -.token.block-comment, -.token.cdata, -.token.comment, -.token.doctype, -.token.prolog { - color: #7d8b99; -} -.token.punctuation { - color: #5f6364; -} -.token.boolean, -.token.constant, -.token.deleted, -.token.function-name, -.token.number, -.token.property, -.token.symbol, -.token.tag { - color: #c92c2c; -} -.token.attr-name, -.token.builtin, -.token.char, -.token.function, -.token.inserted, -.token.selector, -.token.string { - color: #2f9c0a; -} -.token.entity, -.token.operator, -.token.url, -.token.variable { - color: #a67f59; - // background: rgba(255, 255, 255, 0.5); -} -.token.atrule, -.token.attr-value, -.token.class-name, -.token.keyword { - color: #1990b8; -} -.token.important, -.token.regex { - color: #e90; -} -.language-css .token.string, -.style .token.string { - color: #a67f59; - // background: rgba(255, 255, 255, 0.5); -} -.token.important { - font-weight: 400; -} -.token.bold { - font-weight: 700; -} -.token.italic { - font-style: italic; -} -// .token.entity { -// cursor: help; -// } -.token.namespace { - opacity: 0.7; -} @media screen and (max-width: 767px) { pre[class*="language-"]::after, pre[class*="language-"]::before { @@ -481,24 +422,3 @@ pre[class*="language-"] { box-shadow: none; } } -pre[class*="language-"].line-numbers.line-numbers { - padding-left: 0; -} -pre[class*="language-"].line-numbers.line-numbers code { - padding-left: 3.8em; -} -pre[class*="language-"].line-numbers.line-numbers .line-numbers-rows { - left: 0; -} -pre[class*="language-"][data-line] { - padding-top: 0; - padding-bottom: 0; - padding-left: 0; -} -pre[data-line] code { - position: relative; - padding-left: 4em; -} -pre .line-highlight { - margin-top: 0; -} diff --git a/server/ui-src/components/message/Message.vue b/server/ui-src/components/message/Message.vue index a233c51..089c8b7 100644 --- a/server/ui-src/components/message/Message.vue +++ b/server/ui-src/components/message/Message.vue @@ -4,12 +4,15 @@ import Headers from './Headers.vue' import HTMLCheck from './HTMLCheck.vue' import LinkCheck from './LinkCheck.vue' import SpamAssassin from './SpamAssassin.vue' -import Prism from 'prismjs' import Tags from 'bootstrap5-tags' import { Tooltip } from 'bootstrap' import commonMixins from '../../mixins/CommonMixins' import { mailbox } from '../../stores/mailbox' import DOMPurify from 'dompurify' +import hljs from 'highlight.js/lib/core' +import xml from 'highlight.js/lib/languages/xml' + +hljs.registerLanguage('html', xml) export default { props: { @@ -203,10 +206,8 @@ export default { } }, 500) - // html highlighting - window.Prism = window.Prism || {} - window.Prism.manual = true - Prism.highlightAll() + // HTML highlighting + hljs.highlightAll() }, resizeIframe(el) { @@ -608,7 +609,7 @@ export default {