vizoogmbh / u3m

Unified 3D Material (U3M)
http://www.u3m.info
BSD 3-Clause "New" or "Revised" License
40 stars 20 forks source link

Invalid escapes in path regexes #34

Open JoshuaGanter opened 1 year ago

JoshuaGanter commented 1 year ago

The regex patterns inside the relative_file_path and optional_relative_file_path definitions contain some invalid escapes. See following report if they are used with the unicode flag u in javascript:

> RegExp("^((?!(\\.\\.|\\.|\\~|(([cC][oO][nN]|[pP][rR][nN]|[aA][uU][xX]|[cC][lL][oO][cC][kK]\\$|[nN][uU][lL]|[cC][oO][mM][1-9]|[lL][pP][tT][1-9])(\\.[^\\/]*)?))\\/)([^\\x00-\\x1F<>:\"\\/\\\\|\\$\\%]{0,254}[^\\x00-\\x1F<>:\"\\/\\\\|\\$\\%\\.\\x20|]\\/))*(?!(\\.\\.|\\.|\\~|(([cC][oO][nN]|[pP][rR][nN]|[aA][uU][xX]|[cC][lL][oO][cC][kK]\\$|[nN][uU][lL]|[cC][oO][mM][1-9]|[lL][pP][tT][1-9])(\\..*)?))$)([^\\x00-\\x1F<>:\"\\/\\\\|]{0,254}[^\\x00-\\x1F<>:\"\\/\\\\\\.\\x20|]$)$", "u");

Uncaught SyntaxError: Invalid regular expression: /^((?!(\.\.|\.|\~|(([cC][oO][nN]|[pP][rR][nN]|[aA][uU][xX]|[cC][lL][oO][cC][kK]\$|[nN][uU][lL]|[cC][oO][mM][1-9]|[lL][pP][tT][1-9])(\.[^\/]*)?))\/)([^\x00-\x1F<>:"\/\\|\$\%]{0,254}[^\x00-\x1F<>:"\/\\|\$\%\.\x20|]\/))*(?!(\.\.|\.|\~|(([cC][oO][nN]|[pP][rR][nN]|[aA][uU][xX]|[cC][lL][oO][cC][kK]\$|[nN][uU][lL]|[cC][oO][mM][1-9]|[lL][pP][tT][1-9])(\..*)?))$)([^\x00-\x1F<>:"\/\\|]{0,254}[^\x00-\x1F<>:"\/\\\.\x20|]$)$/: Invalid escape

The characters ~ and % should not be escaped.