Skip to content

Commit

Permalink
Update CiteMap.php
Browse files Browse the repository at this point in the history
Properly handle comments
  • Loading branch information
cyberpower678 committed May 14, 2024
1 parent 347f8b8 commit 6527aca
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions app/src/Core/CiteMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -1019,13 +1019,10 @@ protected static function convertToObject( $name, $mapData, $classification ) {
* @return array|bool False on failure
*/
protected static function parseCSConfig( $string ) {
$commentRegex = '/\-\-(?:\[\[(?:.|\n)*?\]\]|.*$)/m';
$parseRegex =
'/(?:local\s+|citation_config\.)([^\s=]*)\s*\=\s*(?:(\{(?:\-\-(?:.*?$|\[\[.*?\]\])|\-|"(?:\\\\"|[^"])*"|\'(?:\\\\\'|[^\'])*\'|[^{}\'"\-]*|(?2))*?\}))/im';
$old = ini_set( 'pcre.jit', false );
$returnArray = [];
// Filter out the comments before parsing the text.
$string = preg_replace( $commentRegex, '', $string );
if( preg_match_all( $parseRegex, $string, $matches ) ) {
foreach( $matches[0] as $tid => $match ) {
$parameter = $matches[1][$tid];
Expand All @@ -1044,7 +1041,7 @@ protected static function parseCSConfig( $string ) {

protected static function parseLuaObject( $string ) {
$parseRegex =
'/\s*(?:\[(\'(?:\\\\\'|[^\'])*\'|"(?:\\\\"|[^"])*")\]\s*=|([^\s\'"]*)\s*=)?\s*(\'(?:\\\\\'|[^\'])*\'|"(?:\\\\"|[^"])*"|(\{(?:"(?:\\\\"|[^"])*?"|\'(?:\\\\\'|[^\'])*?\'|[^{}\'"]*|(?4))*?\})|true|false|null|nil|[0-9a-fx]*(?:\.[0-9a-fx]*)?)\s*[,;]?/i';
'/\s*(?:\[(\'(?:\\\\\'|[^\'])*\'|"(?:\\\\"|[^"])*")\]\s*=|([^\s\'"]*)\s*=)?\s*(\'(?:\\\\\'|[^\'])*\'|"(?:\\\\"|[^"])*"|(\{(?:"(?:\\\\"|[^"])*?"|\'(?:\\\\\'|[^\'])*?\'|[^{}\'"]*|(?4))*?\})|true|false|null|nil|[0-9a-fx]*(?:\.[0-9a-fx]*)?)\s*[,;]?(?:\s*\-\-(?:\[\[(?:.|\n)*?\]\]|.*$)|\s*$)/im';
$string = trim( $string );
if( substr( $string, 0, 1 ) == "{" ) {
$returnArray = [];
Expand Down

0 comments on commit 6527aca

Please sign in to comment.