liqd / aula

An online platform for political participation in schools in Germany (not in active development)
https://liqd.net
Other
27 stars 5 forks source link

Some unicode strings can make edit form rendering crash. #1033

Closed fisx closed 6 years ago

fisx commented 6 years ago

To reproduce, enter the following string in an edit form:

bad :: ST
bad = cs "0\842\788\786\772\770\878\794\875\794\802\824\809\813\796\&1\842\865\863\814\&1\787\876\871\843\838\770\879\843\783\802\857\818\791\846\805\791\798\&0\788\855\794\877\782\823\847\858\817\&0\775\875\780\774\844\776\838\797\858\&1\785\769\782\870\876\829\847\853\805\797\806\846\&1\829\781\875\830\848\871\873\861\837\840\840\796\817\809\&0\771\875\875\820\820\812\809\806\&0\772\870\768\774\869\842\868\861\824\820\852\791\837\854\&1\855\779\874\801\865\852\796\851\&1\785\842\875\875\775\784\775\772\833\823\791\839\858\851\852\828\&1\835\787\770\794\865\823\814\851\&0\769\776\774\855\878\771\835\866\833\861\812\810\805\796\827\846\&1\872\829\773\1161\796\&0\780\830\822\802\860\805\815\805\853\852\854\792\816\798\&1\768\829\872\843\875\843\859\874\865\832\793\819\&0\771\842\798\851\840\841\846\826\803\&1\842\780\771\776\780\875\842\830\871\863\840\&1\877\848\873\869\844\770\787\771\1161\805\841\793\804\797\&0\871\830\831\782\803\819\&0\859\863\806\796\846\858\799\&0\770\784\860\828\839\818\811\&1\838\779\876\871\842\838\823\862\807\841\792\828\828\857\&1\771\772\786\874\768\864\795\851\793\792\828\803\852\845\&0\829\850\838\825\792\845\819\791\792\&1\850\785\872\772\849\863\818\798\827\&1\830\783\879\850\848\786\795\821\812\846\837\840\818\&0\772\847\860\796\819\837\816\826\853\&1\872\872\770\781\872\849\785\850\878\833\832\807\827\811\&0\842\867\787\879\843\772\778\845\826\799\813\854\840\828\814\841\&1\831\872\877\849\784\877\849\878\784\832\807\839\&1\878\848\786\838\849\794\831\845\853\&0\785\778\876\780\872\875\771\835\861\856\806\817\790\800\851\813\846\&0\879\835\878\871\873\877\876\862\810\828\800\805\790\839\837\791\&1\868\870\787\861\807\789\825\819\816\816\799\&0\776\843\876\829\820\853\826\809\&0\830\868\832\864\819\858\792\852\852\852\793\&0\780\835\859\873\770\864\824\862\798\799\814\&0\844\831\769\772\834\849\1161\789\815\851\&0\772\778\838\862\860\866\793\800\846\854\852\816\797\&0\850\843\830\849\794\772\831\869\801\821\827\804\840\858\818\811\&1\842\778\834\867\776\768\788\836\831\828\857\818\837\803\841\846\800\810\&1\836\877\783\844\866\833\814\792\811\853\805\858\815\793\&1\872\786\785\873\871\838\787\794\802\790\812\811\815\799\827\818\&0\784\780\769\794\873\1161\862\813\813\811\799\839\814\845\846\&1\786\860\791\845\800\800\813\804\810\811\826\&0\843\784\773\778\870\877\838\795\862\799\810\846\827\825\790\792\&1\774\856\801\813\791\806\853\800\804\837\810\810\&0\771\835\784\867\874\807\861\807\803\814\811\851\817\803\810\&0\782\873\829\794\875\849\864\866\865\854\846\811\853\853\&0\780\772\829\782\842\808\853\792\&0\871\830\836\770\775\872\864\797\790\&1\877\835\866\823\841\813\814\814\809\839\827\&1\848\871\870\776\855\843\842\779\807\824\820\793\791\791\845\806\796\825\&0\776\873\808\824\791\839\825\811\819\804\&1\849\770\778\849\786\869\822\821\1161\809\826\797\805\819\809\790\813\&0\859\851\839\827\796\851\826\840\&0\876\859\872\789\823\818\819\814\798\846\&0\870\855\771\814\812\827\815\809\809\809\793\&0\838\775\773\788\784\835\873\829\879\821\811\805\846\798\817\&1\794\876\849\850\768\783\782\854\809\857\853\827\840\793\806\809\&0\786\785\860\813\826\853\826\810\&1\775\843\847\865\789\837\800\810\810\&0\842\771\789\823\860\852"

Two effects:

relevant code on hackage:

import Codec.Binary.UTF8.Light  -- http://hackage.haskell.org/package/utf8-light
import Data.ByteString.UTF8  -- http://hackage.haskell.org/package/utf8-string
import Data.Char.Properties  -- http://hackage.haskell.org/package/unicode-properties  -- AHA!
import Data.Char.Properties.Names (getCharacterName)  -- http://hackage.haskell.org/package/unicode-names
import Data.Text.Punycode as Punycode  -- http://hackage.haskell.org/package/punycode  -- doesn't do umlauts properly.  even "wef" => "wef-"
import Data.Text.Normalize as Norm  -- http://hackage.haskell.org/package/unicode-transforms

Fixed in #1034.

My guess is that the unicode string is valid, but triggers a bug in either the showdown library, somwhere in our css/js, or in the browser. "hang" in the description above actually means "takes very long", and with a bit of patience you can get through to deleting it. chromium thinks this string is vietnamese.

What we do in #1034 (after way too much fumbling) is we restrict the allowed characters to basic latin, which should be enough for german and english.