Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix q( ), q{ }, and q[ ] quotes inside PGML [@ @] blocks.
What was happening is that the `my $quoted = '[$@%]q[qr]?|\bq[qr]?\s+(?=.)|\bq[qr]?(?=\W)';` pattern combined with the later `my $chars = '\\\\.|[{}[\]()\'"]';` pattern in the PGML::Parse $splitPattern combined such that an empty string was injected between the `q` and the beginning `(`, `{`, or `[` delimiter. For example the PGML block `[@ q(string) @]` was split into `['[@', ' ', 'q', '', '(', 'string', ')', ' ', '@]']`. The `Quoted` method expected the delimiter to be in the next position after `q`. So this skips that empty string and moves on to the next position in the split in that case. The next part I do not fully understand, and hopefully @dpvc can shed some light on this. When this is parsed until the matching end delimiter is reached it ends by gobbling the end parenthesis (the ending ')' in the list above), and leaves the empty string. If the parser is left with that to continue then a later PGML::Eval is called, and this results in the error `Use of uninitialized value $code in concatenation (.) or string at [PG]/lib/WeBWorK/PG/Translator.pm line 1246` when `PG_restricted_eval` is called. So this also skips to the next split in this case. Furthermore, if the PGML block is `[@ q(string q) @]`, then this is split into `['[@', ' ', 'q', '', '(', 'string ', 'q) ', '', '@]'`. Then at the end of parsing the `q` expression and gobbling the ending parenthesis the split that is left is the ' ' after 'q)'. This results in the same PGML::Eval error later. So this also skips to the next split in this case. Both this case and the previous are handled on line 546 of PGML.pl in this pull request. This fixes issue openwebwork#894.
- Loading branch information