Skip to content

Commit

Permalink
[7_14] Fix crash when pasting the source code of image
Browse files Browse the repository at this point in the history
<!-- Thank you for your contribution! -->
## What
```
<image|<tuple|<#255044462D312E340A25ACDC20ABBA0A312030206F626A0A3C3C202F54797065202F436174616C6F67202F5061676573203220302052203E3E0A656E646F626A0A382030206F626A0A3C3C202F466F6E74203320302052202F584F626A656374203720302052202F457874475374617465203420302052202F5061747465726E2035203020520A2F53686164696E67203620302052202F50726F63536574205B202F504446202F54657874202F496D61676542202F496D61676543202F496D61676549205D203E3E0A656E646F626A0A31312030206F626A0A3C3C202F54797065202F50616765202F506172656E74203220302052202F5265736F75726365732038203020520A2F4D65646961426F78205B20302030203435322E33303636373839393431203333372E393931383735205D202F436F6E74656E7473203920302052202F416E6E6F7473203130203020520A3E3E0A656E646F626A0A392030206F626A0A3C3C202F4C656E67746820313220302052202F46696C746572202F466C6174654465636F6465203E3E0A73747265616D0A789C8D58CB6E5C370CDDDFAFB8CB76515924258A5A367D18C82E89812E8AAED2246D9014480334BFDF43DD99D1C3E38117367C8F2991A2C84352773FBFFBEFEFB7EF5EDFBFD87F7AB3DDF5AFB75F37DA3FE2E7C31EF78FF8F9B6D37E8F9F0F5BC4D7E72D650E12554BC5E7A7F153A4845AC94A061EE7CFBFB6EDFD76F723B6F98A65F7DBC614AA5AB502B960A58961F394039D773BC39F66388672DE75DC64804FCAF850F601C6E320C17014A876648334F6E3BCF3A0BC8331C859F5F602BEF8B67DC1EFB8FF10B1176BA8ACD9056BE062843FDE7EDE5E3C6C77BFD24E717F78DF5CF5F0E7F6FBFE5DFC7EFF637F78B9FDF2B0BDDA9A111B118554CC4C26F5237CD3008A16189EAD5945E93946F015232A07CB9449672306F8B6115683E2DF6CA5303FC788F4D8082E2930274A753262846F5F45A110534A4A35C26DCF30421F1B2139875CB52CD731C2378D106440A2126B76539E63843D362209A24A6B5AAE63846F1A9110BC4A31A6A8169F1598B444A662C31C434A35459B8C1850EA39091B8AE71C672D93F880CEE29502492E4BD60DE82C4E826FE698688ED0015E16E0224833CFE21770112E1C328226CF671DE179019304AA49CB6CFE082F0BC06059103F735C8DF0B22043CC22327B5E30C0CB829A02FC2CCB7D8DF0BC4028854A31E91C6523BC2C901CA05F39CD0B0678595072A852EB726923BC2CA81AD804C79B170CF0BC00B91094C1BE73D48DF0BCE094E56772971AB29D3D85350B782DB94A60647928769363C315AABF68055BE65A0BF278D0DAC1A7B45A0E16D91251CAE9A6F22B147F514E389E52C9F0CDA07D409F528FC444AE81529841B037F55F61F7AEDF6B8564A936E9EFE893FAFDFC62990544C837F55F23F65EE4A1290BA27550DFC1A7B4B39FDE6B6C426CE84DED5718BD6B3F2A65349AD477F449FD7EFA9238821DCB0DF5B2469E8EEAC17FD11419EBDAED117824E15958C11C3596AAA3700767E152028A1E987E14EEE02C4C113C0CD22E93F4802EE2A0247513CB24DED1459C4B20025DCCE21D5DC4BD28A086904DE21D5DC4E101700B9AB349BCA38B387CE05A6516EFE82CCEEE036441AEA3F8802EE2EE83948466F18E2EE2EE8384266D16EFE822EE3EC86572E3055B44FDFCCA345D680717613FBDE23F93F0059C85C5CF0E624A344A0FE822EE67B718E32CDED145DCCF6E681A275B06B4897FD9CFC385AA691AC69184B24352B4B2443885ABCF03FBBFEFF6DFF67F76DE5F227B7DD0F02C7E7DBF8C56D7CB90241C2C99F19ED03B2150C8F352D0E527C9247BC2FFC114D9232761DC22DC36ECA82E4B511CD520066BCA9E4B48B926F68BED8D9B824F58C0378E229DC962DA8B81DE046776D0600E062C74F2EC9191CC4D50F06ACE0215301AC215BB39ACA1803EC5330C1240C5D5F5C6CF4B8BB016F54DD0CC9B1281E6296B48B11D09B0C16D15DD3515F17625B6AD8D31339ADF025A7A8C43A42D940CACE222DE8BC390883870E9A17784216C46D260742711AEF30E41DD49B50541F5AE182AD116C177B0598B4BC38341D03E8070159D83E256B9C1F024F829FB9881FAE69EF21418C73423380225BCC913E68554303B356E2F8209461BEE6556091F1E2A885FA6B60FC248B125E8C3239BE18C7AE025940C8300FBA923EEC2E1DEF60AC5505117526E388A448573A4453CAECE6742C771C45C257A26A0E860FBC6C984608A5CAA28700B3EB6B458C1421037C65A9883510347C8871BCEFDB3201F707385DBEEB84934B226B086DD393860C315534AC4C1618DA78932B71870AEC4F402650D47C8D8E11CB590A41686350CC3ACA22839DEDB70C705A3FDB17F8107917AB5C11907B7768586A297309253C30B763C0E6BF8A08456B5E1D0799CC970704CAE961B5C994E3EEEC36FC34B8AC7362DC5235C043C8788AE34BB951C711166E504A349395E25223E7241D376E038480B628E15F5451199078EE64BADBD625C4688036F2F1A8E236BE18FA8075E445B0D66DC8480E9E5A4B7E0F20F3C23BDA0F9049BB6D284DE2D2475FB4F7845B838DE0791865B3CF281A5788F929CF41A4E8D8E308FA361C98891339C12371C9D314ECE76C6B51521CF318CA092EB19F73CFD348E3367DC9A99602E3089F2D91CB2431E2414FDEF8B39471E325808AD80D9C59EA3563268887206C55D706DC7ED8F0A67BC6D53FC31C5A7E50EB7638189904989BA3987770C1C2618B4D3823B5DA158946ECE110C7D185B70F3EED79973C29D0B4A4CB9D08A83C9402A51161C6480F9C024ADF865A65B70F02E08B12EF6785A46B011AFF6B41EAA3D34CD38F8083751EB6A4F1F0D17DC4B027B6338E309EC8B34B6D59ED40A59A6D59E0C1A02F1E6D59EFE5CB3E0A05F45D3B0DAA3029E4870D08A171FB9B4ACF6943655A2815BF1CB643BE3A0A4889A5D78C5417370735CED0127A1AA9BACF6809350EEC10E2B7E1990271C0410E0A322B4E2296094F0316AC1C1C06638C08213181854CBBAE297397BC651349CD66DB5C7F91881CEAB3DE8BC0C3525AFF6083A8008F25AEDE92F6113BEBDD95EED5F5ADF152FCFBC73D3D57BAE6B8FBDD3CB3176EB6FCA7CFD619A878769D7BEFD0F39C7977A0A656E6473747265616D0A656E646F626A0A31322030206F626A0A313835330A656E646F626A0A31302030206F626A0A5B205D0A656E646F626A0A31372030206F626A0A3C3C202F4C656E67746820333935202F46696C746572202F466C6174654465636F6465203E3E0A73747265616D0A789C3D524B6EC54008DBE7145CA0D2F09BCF795255DDBCFB6F6B4352A92ABC8931C6307DCA90B9E54B5D127185C9B75EAE5B3CA67C2E5B5A997988BB8B8D253EB6DC97EE21B65D742EB1381D47F20B329D2A44A8CDAAD1A1F842968507904EF0A10BC27D39FEE32F80C1D7B00DB8E13D3241B024E62942C66E51199A12411161E79115A8A4509F59C2DF51EEEBF732056A6F8CA50B631CF409B405426D48C402EA400044EC9454AD908E672413BF15DD67621C60E7D1B201AE195444967BECC788A9CEA88CBC44C43E4F4DFA28964C2D56C66E53195FFC948CD47C74052AA934F294F2D055B3D00B58897912F639FC48F8E7D66C21863A6ED6F289E51F33C53212CE604B3960A197E347E0DB597511AE1DB9B8CE74811F95D6704CB4EB7EC8F54FFE74DB5ACD75BC7208A240E54D41F0BB0EAE46B1C4C4323E9D8D297AA22CB01A9ABC4633C1611011D6F7C3C8031AFD72BC1034A76B22B458229BB562448D8A6C733DBD04D64CEFC539D6C313C26CEF9DD6A1B233332A2182DABA866AEB4076B3BEF370B69F3F33E8A26D0A656E6473747265616D0A656E646F626A0A31382030206F626A0A3C3C202F4C656E677468203934202F46696C746572202F466C6174654465636F6465203E3E0A73747265616D0A789C458DC111C0200804FF5441090A0ADA4F269387F6FF8D10327C60E70EEE84050BB679461F0595265E1558074A63DC508F40BDE1722DC9DC050F70277FDAD0549C96D3776991495529DCA41279FF0E672690A879D1639DF70B63FB233C0A656E6473747265616D0A656E646F626A0A31392030206F626A0A3C3C202F4C656E677468203833202F46696C746572202F466C6174654465636F6465203E3E0A73747265616D0A789C458CBB0DC03008447BA660047E26F63E5194C2DEBF0D10256EB827DD3D5C1D0999296E33C343069E0C2C865D7181F496300B5C47508E9DECA361D5BEEA048DF5A652F3EF0F949EECACE286EB0102421A660A656E6473747265616D0A656E646F626A0A32302030206F626A0A3C3C202F4C656E677468203531202F46696C746572202F466C6174654465636F6465203E3E0A73747265616D0A789C3336B45030503034300792468640969189428A21174800C4CCE58209E6805906401AA23807AE26872B832B0D00E1B40D980A656E6473747265616D0A656E646F626A0A32312030206F626A0A3C3C202F4C656E67746820333230202F46696C746572202F466C6174654465636F6465203E3E0A73747265616D0A789C35524B6E053108DBCF29B840A5F04FCEF3AAAA8BBEFB6F6B13BD154C3060E3292F59D24BBED425DBA5C3E45B1FF725B142DE8FED9ACC52C5F716B314CF2DAF47CF11B72D0A0451133D58992F1522D4CFF4E83AA8704A9F815708B7141BBC834900836AF8071EA5332050E740C6BB623252038224D873697108897226897FA4BC9EDF27ADA4A1F43D5999CBDF934BA5D01D4D4EE801C5CAC549A05D49F9A099984A449297EB7DB142F486C0923C3E4731C980EC36896DA20526E71EA525CCC4143AB0C702BC669AD555E860C21E87298C570BB3A81E6CF25B1395A41DADE319D930DECB305362A1E1B005D4E6626582EEE5E335AFC288ED51935DC370EE96CD7708D168FE1B16CAE06315928047A7B1120D6938C088C09E5E38C55EF313390EC088639D9A2C0C636826A77A8E89C0D09EB3A561C6C71E5AF5F30F54E97C870A656E6473747265616D0A656E646F626A0A32322030206F626A0A3C3C202F4C656E67746820333430202F46696C746572202F466C6174654465636F6465203E3E0A73747265616D0A789C3552396E04310CEBFD0A7D20806EDBEFD9204891FCBF0DA9D91403717452943B5A5476CB878554B5EC74F9B495DA1237E4776585C409C9AB12ED528648A8BC5621D5EF9932AFB7356704C852A5C2E4A4E471C9823FC3A5A70BC7F9B6B1AFE5C81D8F1E581523A144C032C5C4E81A96CEEEB0665B7E9669C08F78849C2BD62DC75805521BDD38ED8AF7A1792DB20688BD99968A0A1D5689167E41F1A0478D7DF618545820D1ED1C49708C895091807681DA480C397B2C76511FF433283113E8DA1B45DC418125929839C5BA74F4DFF8D0B1A0FED88C37BF3A2AE95B5A5963D23E1BED94C62C32E97A58F474F3D6C7830B34EFA2FCE7D50C1234658D92C607ADDA3986A299515678B743930DCD31C721F30E9EC319094AFA3C14BF8F25131D94C8DF0E0DA17F5F1EA38C9C36DE02E6A23F6D15070EE2B3C35EB981154A176B92F701A94CE881E9FFAFF1B5BED7D71F1DED80C60A656E6473747265616D0A656E646F626A0A32332030206F626A0A3C3C202F4C656E67746820323531202F46696C746572202F466C6174654465636F6465203E3E0A73747265616D0A789C2D514972034108BBCF2BF48466A7DF63972B87E4FFD708CA07060D8B40745AE2A08C9F202C57BCE591AB68C3DF333182DF05877E2BD76D58E440542049635035A176F17AF41ED8719809CC93D6B00C66AC0FFC8C29DCE8C5E1311967B7D765D410EC5DAF3D9941C9AC5CC42513174CD56123670E3F99322EB4733D3720E746589761906E561A33128E3485482185AA9BA4CE0441128CAE468D367214FBA52F8F7486558DA831EC732D6D5FCF4D386BD0EC58ACF2E4941E5D712E27172FAC1CF4F53603175169ACF24048C0FD6E0FF573B293DF784BE7CE16D3E37BCDC9F2C25460C59BD76E4036D5E2DFBC88E3FB8CAFE7E7F9FC035F605B880A656E6473747265616D0A656E646F626A0A32342030206F626A0A3C3C202F4C656E67746820323135202F46696C746572202F466C6174654465636F6465203E3E0A73747265616D0A789C3551390E03210CECF715FE40248C2F784FA228CDFEBFCD8CD1561EC15C86B4942199F25293A821E5533E7A992E9CBADCD7CC6A34E796B42D7380B8B6BC2FAD92C089668883C16998B8019A3C0143D7D1A85143171ED0D4A55328B0DC043E8AB76E0FDD63B58197B621E789206228192C41CDA94513166DCF27A435BF5E8B1BDE97EDDDC853A5C6961881060156381CD7E8D7F0953D4F26D1741532D4AB35CB18091345223CF98EA6D513EB5A34D23212D4C611AC6A03BC3BFD304E00001371CB02649F4A94B3E4C46FB1F4B30657FAFE019F4754960A656E6473747265616D0A656E646F626A0A31352030206F626A0A3C3C202F54797065202F466F6E74202F42617365466F6E74202F424D515144562B44656A61567553616E73202F4669727374436861722030202F4C61737443686172203235350A2F466F6E7444657363726970746F7220313420302052202F53756274797065202F5479706533202F4E616D65202F424D515144562B44656A61567553616E730A2F466F6E7442426F78205B202D31303231202D34363320313739342031323333205D202F466F6E744D6174726978205B20302E3030312030203020302E30303120302030205D0A2F4368617250726F6373203136203020520A2F456E636F64696E67203C3C202F54797065202F456E636F64696E670A2F446966666572656E636573205B203436202F706572696F64203438202F7A65726F202F6F6E65202F74776F202F7468726565202F666F7572203534202F736978203536202F6569676874205D0A3E3E0A2F57696474687320313320302052203E3E0A656E646F626A0A31342030206F626A0A3C3C202F54797065202F466F6E7444657363726970746F72202F466F6E744E616D65202F424D515144562B44656A61567553616E73202F466C6167732033320A2F466F6E7442426F78205B202D31303231202D34363320313739342031323333205D202F417363656E7420393239202F44657363656E74202D323336202F43617048656967687420300A2F584865696768742030202F4974616C6963416E676C652030202F5374656D562030202F4D617857696474682031333432203E3E0A656E646F626A0A31332030206F626A0A5B2036303020363030203630302036303020363030203630302036303020363030203630302036303020363030203630302036303020363030203630302036303020363030203630300A3630302036303020363030203630302036303020363030203630302036303020363030203630302036303020363030203630302036303020333138203430312034363020383338203633360A3935302037383020323735203339302033393020353030203833382033313820333631203331382033333720363336203633362036333620363336203633362036333620363336203633360A3633362036333620333337203333372038333820383338203833382035333120313030302036383420363836203639382037373020363332203537352037373520373532203239350A3239352036353620353537203836332037343820373837203630332037383720363935203633352036313120373332203638342039383920363835203631312036383520333930203333370A3339302038333820353030203530302036313320363335203535302036333520363135203335322036333520363334203237382032373820353739203237382039373420363334203631320A3633352036333520343131203532312033393220363334203539322038313820353932203539322035323520363336203333372036333620383338203630302036333620363030203331380A33353220353138203130303020353030203530302035303020313334322036333520343030203130373020363030203638352036303020363030203331382033313820353138203531380A35393020353030203130303020353030203130303020353231203430302031303233203630302035323520363131203331382034303120363336203633362036333620363336203333370A353030203530302031303030203437312036313220383338203336312031303030203530302035303020383338203430312034303120353030203633362036333620333138203530300A3430312034373120363132203936392039363920393639203533312036383420363834203638342036383420363834203638342039373420363938203633322036333220363332203633320A3239352032393520323935203239352037373520373438203738372037383720373837203738372037383720383338203738372037333220373332203733322037333220363131203630350A3633302036313320363133203631332036313320363133203631332039383220353530203631352036313520363135203631352032373820323738203237382032373820363132203633340A36313220363132203631322036313220363132203833382036313220363334203633342036333420363334203539322036333520353932205D0A656E646F626A0A31362030206F626A0A3C3C202F656967687420313720302052202F666F757220313820302052202F6F6E6520313920302052202F706572696F6420323020302052202F736978203231203020520A2F746872656520323220302052202F74776F20323320302052202F7A65726F20323420302052203E3E0A656E646F626A0A332030206F626A0A3C3C202F463120313520302052203E3E0A656E646F626A0A342030206F626A0A3C3C202F4131203C3C202F54797065202F457874475374617465202F43412030202F63612031203E3E0A2F4132203C3C202F54797065202F457874475374617465202F43412031202F63612031203E3E203E3E0A656E646F626A0A352030206F626A0A3C3C203E3E0A656E646F626A0A362030206F626A0A3C3C203E3E0A656E646F626A0A372030206F626A0A3C3C203E3E0A656E646F626A0A322030206F626A0A3C3C202F54797065202F5061676573202F4B696473205B20313120302052205D202F436F756E742031203E3E0A656E646F626A0A32352030206F626A0A3C3C202F43726561746F7220284D6174706C6F746C69622076332E392E322C2068747470733A2F2F6D6174706C6F746C69622E6F7267290A2F50726F647563657220284D6174706C6F746C696220706466206261636B656E642076332E392E32290A2F4372656174696F6E446174652028443A32303234313130363139323934322B30382730302729203E3E0A656E646F626A0A787265660A302032360A303030303030303030302036353533352066200A30303030303030303136203030303030206E200A30303030303036353936203030303030206E200A30303030303036343032203030303030206E200A30303030303036343334203030303030206E200A30303030303036353333203030303030206E200A30303030303036353534203030303030206E200A30303030303036353735203030303030206E200A30303030303030303635203030303030206E200A30303030303030333438203030303030206E200A30303030303032323937203030303030206E200A30303030303030323038203030303030206E200A30303030303032323736203030303030206E200A30303030303035323232203030303030206E200A30303030303035303135203030303030206E200A30303030303034363437203030303030206E200A30303030303036323735203030303030206E200A30303030303032333137203030303030206E200A30303030303032373835203030303030206E200A30303030303032393531203030303030206E200A30303030303033313036203030303030206E200A30303030303033323239203030303030206E200A30303030303033363232203030303030206E200A30303030303034303335203030303030206E200A30303030303034333539203030303030206E200A30303030303036363536203030303030206E200A747261696C65720A3C3C202F53697A65203236202F526F6F74203120302052202F496E666F20323520302052203E3E0A7374617274787265660A363831330A2525454F460A>|pdf>|0.618par|||>
```

## How to test your changes?
Copy and paste it to Mogan, it will crash Mogan.
  • Loading branch information
da-liii authored Nov 13, 2024
1 parent a7d5b1d commit 4051431
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/Graphics/Fonts/smart_font.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,10 +268,15 @@ init_unicode_substitution () {

int
get_utf8_code (string c) {
int c_N= N (c);
if (c_N <= 2 || c_N > 6) {
// the largest unicode is U+10FFFF
return -1;
}
string uc = strict_cork_to_utf8 (c);
int pos = 0;
int code= decode_from_utf8 (uc, pos);
if (pos == N (uc)) return code;
if (pos == c_N) return code;
else return -1;
}

Expand Down
6 changes: 5 additions & 1 deletion src/Plugins/Freetype/unicode_font.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -816,7 +816,11 @@ unicode_font_rep::index_glyph (string s, font_metric& rm, font_glyphs& rg) {

static bool
is_math_italic (string c) {
if (N (c) <= 2) return false;
int c_N= N (c);
if (c_N <= 2 || c_N > 6) {
// the largest unicode is U+10FFFF
return false;
}
int i = 0;
int code= decode_from_utf8 (strict_cork_to_utf8 (c), i);
if (code < 0x2100 || code > 0x1d7ff) return false;
Expand Down

0 comments on commit 4051431

Please sign in to comment.