Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[phpdoc] Page crashes when annotation type is too long #2197

Closed
nterray opened this issue Feb 4, 2020 · 2 comments · Fixed by #2198
Closed

[phpdoc] Page crashes when annotation type is too long #2197

nterray opened this issue Feb 4, 2020 · 2 comments · Fixed by #2198

Comments

@nterray
Copy link

nterray commented Feb 4, 2020

Information:

  • Prism version: 1.17.1 & 1.19.0
  • Plugins: language-phpdoc
  • Environment: Browser

Description
When the php annotation @var is referencing a type with a long name, the page crashes (at least Firefox & Chromium in their latest version).

Example
For example this code snippet will fail (See corresponding jsfiddle)…

<!DOCTYPE html>
<meta charset="utf-8">
<link href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.19.0/themes/prism.min.css" rel="stylesheet" />
<pre><code class="language-phpdoc">&lt;?php
class ProjectCreator
{
    /** @var Git_Driver_Gerrit_ProjectCreator_Factory */
    private $factory;
}
</code></pre>
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.19.0/components/prism-core.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.19.0/plugins/autoloader/prism-autoloader.min.js"></script>

… whereas this code snippet will be ok (See corresponding jsfiddle)

<!DOCTYPE html>
<meta charset="utf-8">
<link href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.19.0/themes/prism.min.css" rel="stylesheet" />
<pre><code class="language-phpdoc">&lt;?php
class ProjectCreator
{
    /** @var Git_Driver_Gerrit */
    private $factory;
}
</code></pre>
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.19.0/components/prism-core.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.19.0/plugins/autoloader/prism-autoloader.min.js"></script>

Best regards,
Nicolas

@RunDevelopment
Copy link
Member

RunDevelopment commented Feb 4, 2020

Seems like I messed up and one of the regexes takes exponential time to fail. I'll make a fix.

Thank you for reporting!

@nterray
Copy link
Author

nterray commented Feb 4, 2020

Thanks for the fix! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants