Skip to content

Commit

Permalink
PHPDoc: Fixed exponential backtracking (PrismJS#2198)
Browse files Browse the repository at this point in the history
This fixed the exponential backtracking of the pattern which matched PHP classes.
  • Loading branch information
RunDevelopment authored and catb0t committed Feb 7, 2020
1 parent a48ef21 commit 6ffec4d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion components/prism-phpdoc.js
@@ -1,6 +1,6 @@
(function (Prism) {

var typeExpression = /(?:[a-zA-Z]\w*|[|\\[\]])+/.source;
var typeExpression = /(?:\b[a-zA-Z]\w*|[|\\[\]])+/.source;

Prism.languages.phpdoc = Prism.languages.extend('javadoclike', {
'parameter': {
Expand Down
2 changes: 1 addition & 1 deletion components/prism-phpdoc.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions tests/languages/phpdoc/issue2197.test
@@ -0,0 +1,16 @@
/** @var Git_Driver_Gerrit_ProjectCreator_Factory */

----------------------------------------------------

[
"/** ",
["keyword", "@var"],
["class-name", [
"Git_Driver_Gerrit_ProjectCreator_Factory"
]],
" */"
]

----------------------------------------------------

Checks exponential backtracking for types. See #2197.

0 comments on commit 6ffec4d

Please sign in to comment.