@@ -45,10 +45,27 @@ const checkFileIntegrity = async (feeds) => {
4545 return feeds ;
4646}
4747
48+ const unescapeLuaString = ( string ) => {
49+ // Source https://www.lua.org/pil/2.4.html
50+ string = string . replaceAll ( "\\a" , "" ) ; // bell
51+ string = string . replaceAll ( "\\b" , "\b" ) ; // back space
52+ string = string . replaceAll ( "\\f" , "\f" ) ; // form feed
53+ string = string . replaceAll ( "\\n" , "\n" ) ; // newline
54+ string = string . replaceAll ( "\\r" , "\r" ) ; // carriage return
55+ string = string . replaceAll ( "\\t" , "\t" ) ; // horizontal tab
56+ string = string . replaceAll ( "\\v" , "\v" ) ; // vertical tab
57+ string = string . replaceAll ( "\\\"" , "\"" ) ; // double quote
58+ string = string . replaceAll ( "\\'" , "'" ) ; // single quote
59+ string = string . replaceAll ( "\\[" , "[" ) ; // left square bracket
60+ string = string . replaceAll ( "\\]" , "]" ) ; // right square bracket
61+ string = string . replaceAll ( "\\\\" , "\\" ) ; // backslash
62+ return string
63+ }
64+
4865const extractProperty = ( script , property ) => {
4966 var match = Array . from ( script . matchAll ( new RegExp ( `\\s*${ property } \\s*=\\s*(?:tr)?(?:"([^"]*)"|'([^']*)')` , 'g' ) ) ) ;
5067 if ( match . length === 1 ) {
51- return ( match [ 0 ] [ 1 ] || "" ) + ( match [ 0 ] [ 2 ] || "" ) ;
68+ return unescapeLuaString ( ( match [ 0 ] [ 1 ] || "" ) + ( match [ 0 ] [ 2 ] || "" ) ) ;
5269 }
5370 return null ;
5471}
@@ -59,7 +76,7 @@ const extractFeedData = (script) => {
5976 feedData = match [ 0 ] [ 1 ] ;
6077 var feed = Array . from ( feedData . matchAll ( / ^ [ ^ { ] * f e e d \s * [: = ] \s * [ " ' ] ( [ ^ " ' ] + ) [ " ' ] / g) ) ;
6178 if ( feed . length === 1 ) {
62- return { feed : feed [ 0 ] [ 1 ] }
79+ return { feed : feed [ 0 ] [ 1 ] }
6380 }
6481 }
6582 return null ;
0 commit comments