atlas-engineer / nyxt

Nyxt - the hacker's browser.
https://nyxt-browser.com/
9.86k stars 413 forks source link

nyxt escapes characters in CSS #1830

Closed xaltsc closed 1 year ago

xaltsc commented 3 years ago

Describe the bug

When specifying a style string for buffers, characters like >, even though meaningful in CSS, are escaped to their html escape sequence, in this case, >.

Precise recipe to reproduce the issue

Put this in your configuration:

(define-configuration status-buffer
  ((style "whatever>direct-child { property: value; }" )))

And inspect the status buffer. (Note that the style slot of the status buffer is correct).

Information

Nyxt version: 2.0.0
Renderer version: GI-GTK
Operating system kernel: Linux 5.7.19_1
Lisp implementation: SBCL 2.1.5
Features: (WEBKIT2 WEBKIT2-2.32 WEBKIT2-PASTE-PLAINTEXT WEBKIT2-TRACKING WEBKIT2-MUTE
 WEBKIT2-EMOJI WEBKIT2-MEDIA WEBKIT2-SANDBOXING GTK-3-22 GTK-3-20 GTK-3-18
 GTK-3-16 GTK-3-14 GTK-3-12 GTK-3-10 GTK-3-8 GTK-3-6 GTK-3-4 GTK GDK-3-22
 GDK-3-20 GDK-3-18 GDK-3-16 GDK-3-14 GDK-3-12 GDK-3-10 GDK-3-8 GDK-3-6 GDK-3-4
 CAIRO-1-10 CAIRO-1-12 GDK-PIXBUF GLIB-2-30 GLIB-2-32 GLIB-2-34 GLIB-2-36
 GLIB-2-38 GLIB-2-40 GLIB-2-42 GLIB-2-44 GLIB-2-46 GLIB-2-48 GLIB-2-50
 GLIB-2-52 GLIB-2-54 GLIB-2-56 GLIB-2-58 GLIB NYXT-2 FSET-EXT-STRINGS
 CUSTOM-HASH-TABLE-NATIVE SWANK PLUMP-UTF-32 CL-PPCRE-UNICODE GLOBAL-VARS
 DECLARE-TYPES PARENSCRIPT SBCL+SAFE-STANDARD-READTABLE NAMED-READTABLES
 21BIT-CHARS CHUNGA GRAY-STREAMS FAST-IO-SV FAST-IO SBCL-USES-SB-ROTATE-BYTE
 ASDF-SYSTEM-CONNECTIONS CLOSER-MOP SPLIT-SEQUENCE CL-UNICODE FLEXI-STREAMS
 CL-PPCRE CL-JSON-DOUBLE-FLOAT-IS-SUBSUMED CL-JSON-SINGLE-FLOAT-IS-SUBSUMED
 CL-JSON-CLOS CL-JSON BORDEAUX-THREADS THREAD-SUPPORT FLAT-NAMESPACE X86-64
 UNIX CFFI FLAT-NAMESPACE SEQUENCE-EMPTYP QUICKLISP ASDF3.3 ASDF3.2 ASDF3.1
 ASDF3 ASDF2 ASDF OS-UNIX NON-BASE-CHARS-EXIST-P ASDF-UNICODE X86-64 GENCGC
 64-BIT ANSI-CL COMMON-LISP ELF IEEE-FLOATING-POINT LINUX LITTLE-ENDIAN
 PACKAGE-LOCAL-NICKNAMES SB-CORE-COMPRESSION SB-LDB SB-PACKAGE-LOCKS SB-THREAD
 SB-UNICODE SBCL UNIX)

ASDF version: 3.3.1
Critical dependencies: (/builddir/nyxt/_build/submodules/cl-cffi-gtk/gtk/cl-cffi-gtk.asd
 /builddir/nyxt/_build/quicklisp-client/dists/quicklisp/software/cl-gobject-introspection-20210124-git/cl-gobject-introspection.asd
 /builddir/nyxt/_build/submodules/cl-webkit/webkit2/cl-webkit2.asd)

Quicklisp dist version: 2021-05-31
Quicklisp client version: 2020-01-04
Local project directories: (/builddir/nyxt/_build/submodules/
 /builddir/nyxt/_build/quicklisp-client/local-projects/)
Critical dependencies(#<SYSTEM cl-cffi-gtk / cl-cffi-gtk-20201220-git / quicklisp 2021-05-31>
 #<SYSTEM cl-gobject-introspection / cl-gobject-introspection-20210124-git / quicklisp 2021-05-31>
 #<SYSTEM cl-webkit2 / cl-webkit-20210531-git / quicklisp 2021-05-31>)

Output when started from a shell I am not running a minimal config here

<INFO> [11:46:57] Listening to socket "/home/ax/.tmp/run/nyxt/nyxt.socket".
Nyxt version 2.0.0
<INFO> [11:46:57] Loading Lisp file "/home/ax/.config/nyxt/init.lisp".
<INFO> [11:46:57] Loading Lisp file "~/.config/nyxt/status.lisp".
WARNING: redefining NYXT:FORMAT-STATUS-TABS in DEFUN
WARNING: redefining NYXT:FORMAT-STATUS-URL in DEFUN

; file: /home/ax/.config/nyxt/status.lisp
; in: DEFUN FORMAT-STATUS-MODES
;     (DEFUN NYXT:FORMAT-STATUS-MODES (NYXT:BUFFER NYXT:WINDOW)
;       (LET* ((NYXT-USER::VISIBLE-P (LAMBDA # #))
;              (NYXT-USER::BUFMODES (SERAPEUM:FILTER NYXT-USER::VISIBLE-P #)))
;         (MAP 'LIST #'NYXT-USER::FORMAT-MODE NYXT-USER::BUFMODES)))
; 
; caught STYLE-WARNING:
;   The variable WINDOW is defined but never used.
; 
; compilation unit finished
;   caught 1 STYLE-WARNING condition
WARNING: redefining NYXT:FORMAT-STATUS-MODES in DEFUN
<INFO> [11:46:58] Loading Lisp file "~/.config/nyxt/themes/2109.lisp".
<INFO> [11:47:06] Loading history of 135 URLs from "/home/ax/.local/share/nyxt/history/default.lisp".
dtw-waleee commented 3 years ago

You need to change it a bit, example from ericdrgn's config, https://github.com/ericdrgn/drgn.nyxt/blob/main/themes/drgn-dark.lisp#L105

Regarding the escape of '>' I think that's due to (style ...) defaulting to spinneret for styling.

aartaka commented 2 years ago

Okay, I was too quick to close it. 05f207684763f9cff059886e611e0c8341b2d16b doesn't (yet?) fix the problem, as it introduces subtle bugs with Spinneret and CL-CSS messing with each other.