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

Severe syntax errors crash the application #14

Open
Kijewski opened this issue Aug 20, 2024 · 1 comment · Fixed by #16
Open

Severe syntax errors crash the application #14

Kijewski opened this issue Aug 20, 2024 · 1 comment · Fixed by #16

Comments

@Kijewski
Copy link
Collaborator

Kijewski commented Aug 20, 2024

Stack trace:

panicked at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/syntect-5.2.0/src/parsing/regex.rs:70:53:
regex string should be pre-tested: ParseError(147, InvalidEscape("\\g"))

Stack:

__wbg_get_imports/imports.wbg.__wbg_new_abda76e883ba8a5f@https://rinja-rs.github.io/play-rinja/play-rinja-4ead1919bf12f84e.js:415:21
@https://rinja-rs.github.io/play-rinja/play-rinja-4ead1919bf12f84e_bg.wasm:wasm-function[1153]:0x111e48
@https://rinja-rs.github.io/play-rinja/play-rinja-4ead1919bf12f84e_bg.wasm:wasm-function[2621]:0x13c53b
@https://rinja-rs.github.io/play-rinja/play-rinja-4ead1919bf12f84e_bg.wasm:wasm-function[1526]:0x120418
@https://rinja-rs.github.io/play-rinja/play-rinja-4ead1919bf12f84e_bg.wasm:wasm-function[193]:0x81eff
@https://rinja-rs.github.io/play-rinja/play-rinja-4ead1919bf12f84e_bg.wasm:wasm-function[495]:0xdfe63
@https://rinja-rs.github.io/play-rinja/play-rinja-4ead1919bf12f84e_bg.wasm:wasm-function[127]:0x461c9
@https://rinja-rs.github.io/play-rinja/play-rinja-4ead1919bf12f84e_bg.wasm:wasm-function[98]:0x10164
@https://rinja-rs.github.io/play-rinja/play-rinja-4ead1919bf12f84e_bg.wasm:wasm-function[306]:0xa8834
@https://rinja-rs.github.io/play-rinja/play-rinja-4ead1919bf12f84e_bg.wasm:wasm-function[449]:0xd9811
@https://rinja-rs.github.io/play-rinja/play-rinja-4ead1919bf12f84e_bg.wasm:wasm-function[640]:0xef794
@https://rinja-rs.github.io/play-rinja/play-rinja-4ead1919bf12f84e_bg.wasm:wasm-function[3358]:0x1467f9
__wbg_adapter_31@https://rinja-rs.github.io/play-rinja/play-rinja-4ead1919bf12f84e.js:254:10
real@https://rinja-rs.github.io/play-rinja/play-rinja-4ead1919bf12f84e.js:239:20
VoidFunction*__wbg_get_imports/imports.wbg.__wbg_queueMicrotask_12a30234db4045d3@https://rinja-rs.github.io/play-rinja/play-rinja-4ead1919bf12f84e.js:502:23
@https://rinja-rs.github.io/play-rinja/play-rinja-4ead1919bf12f84e_bg.wasm:wasm-function[1106]:0x10f736
@https://rinja-rs.github.io/play-rinja/play-rinja-4ead1919bf12f84e_bg.wasm:wasm-function[1435]:0x11d4b1
@https://rinja-rs.github.io/play-rinja/play-rinja-4ead1919bf12f84e_bg.wasm:wasm-function[402]:0xd2c0d
@https://rinja-rs.github.io/play-rinja/play-rinja-4ead1919bf12f84e_bg.wasm:wasm-function[459]:0xdb08e
@https://rinja-rs.github.io/play-rinja/play-rinja-4ead1919bf12f84e_bg.wasm:wasm-function[4078]:0x14cd36
__wbg_finalize_init@https://rinja-rs.github.io/play-rinja/play-rinja-4ead1919bf12f84e.js:754:10
__wbg_init@https://rinja-rs.github.io/play-rinja/play-rinja-4ead1919bf12f84e.js:802:12
async*@https://rinja-rs.github.io/play-rinja/:21:20

Struct:

"#[derive(Template)]\n#[template(ext = \"html\")]\n// in the preview, the `source=\"\"` or `path=\"\"` argument is provided for you\n        struct PageLayout<'a> {\n            static_root_path: String,\n            page: &'a Page<'a>,\n            layout: &'a Layout,\n            files: &'static StaticFiles,\n            themes: Vec<String>,\n            sidebar: String,\n            content: String,\n            rust_channel: &'static str,\n            pub(crate) rustdoc_version: &'a str,\n            display_krate: &'a str,\n            display_krate_with_trailing_slash: String,\n            display_krate_version_number: &'a str,\n            display_krate_version_extra: &'a str,\n        }"

Template:

"<!DOCTYPE html> {# #}\n<html lang=\"en\"> {# #}\n<head> {# #}\n    <meta charset=\"utf-8\"> {# #}\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"> {# #}\n    <meta name=\"generator\" content=\"rustdoc\"> {# #}\n    <meta name=\"description\" content=\"{{page.description}}\"> {# #}\n    <title>{{page.title}}</title> {# #}\n    <script>if(window.location.protocol!==\"file:\") {# Hack to skip preloading fonts locally - see #98769 #}\n    document.head.insertAdjacentHTML(\"beforeend\",\"{{files.source_serif_4_regular}},{{files.fira_sans_regular}},{{files.fira_sans_medium}},{{files.source_code_pro_regular}},{{files.source_code_pro_semibold}}\".split(\",\").map(f=>`<link rel=\"preload\" as=\"font\" type=\"font/woff2\" crossorigin href=\"{{static_root_path|safe}}${f}\">`).join(\"\")) {# #}\n    </script> {# #}\n    <link rel=\"stylesheet\" {#+ #}\n          href=\"{{static_root_path|safe}}{{files.normalize_css}}\"> {# #}\n    <link rel=\"stylesheet\" {#+ #}\n          href=\"{{static_root_path|safe}}{{files.rustdoc_css}}\"> {# #}\n    {% if !layout.default_settings.is_empty() %}\n    <script id=\"default-settings\" {#+ #}\n      {%~ for (k, v) in layout.default_settings ~%}\n        data-{{k}}=\"{{v}}\"\n      {% endfor %}\n    ></script> {# #}\n    {% endif %}\n    <meta name=\"rustdoc-vars\" {#+ #}\n         data-root-path=\"{{page.root_path|safe}}\" {#+ #}\n         data-static-root-path=\"{{static_root_path|safe}}\" {#+ #}\n         data-current-crate=\"{{layout.krate}}\" {#+ #}\n         data-themes=\"{{themes|join(\",\") }}\" {#+ #}\n         data-resource-suffix=\"{{page.resource_suffix}}\" {#+ #}\n         data-rustdoc-version=\"{{rustdoc_version}}\" {#+ #}\n         data-channel=\"{{rust_channel}}\" {#+ #}\n         data-search-js=\"{{files.search_js}}\" {#+ #}\n         data-settings-js=\"{{files.settings_js}}\" {#+ #}\n    > {# #}\n    <script src=\"{{static_root_path|safe}}{{files.storage_js}}\"></script> {# #}\n    {% if page.css_class.contains(\"crate\") %}\n    <script defer src=\"{{page.root_path|safe}}crates{{page.resource_suffix}}.js\"></script> {# #}\n    {% else if page.css_class == \"src\" %}\n    <script defer src=\"{{static_root_path|safe}}{{files.src_script_js}}\"></script> {# #}\n    <script defer src=\"{{page.root_path|safe}}src-files{{page.resource_suffix}}.js\"></script> {# #}\n    {% else if !page.css_class.contains(\"mod\") %}\n    <script defer src=\"sidebar-items{{page.resource_suffix}}.js\"></script> {# #}\n    {% else if !page.css_class.contains(\"sys\") %}\n    <script defer src=\"../sidebar-items{{page.resource_suffix}}.js\"></script> {# #}\n    {% endif %}\n    <script defer src=\"{{static_root_path|safe}}{{files.main_js}}\"></script> {# #}\n    {% if layout.scrape_examples_extension %}\n    <script defer src=\"{{static_root_path|safe}}{{files.scrape_examples_js}}\"></script> {# #}\n    {% endif %}\n    <noscript> {# #}\n        <link rel=\"stylesheet\" {#+ #}\n           href=\"{{static_root_path|safe}}{{files.noscript_css}}\"> {# #}\n    </noscript> {# #}\n    {% if layout.css_file_extension.is_some() %}\n        <link rel=\"stylesheet\" {#+ #}\n            href=\"{{page.root_path|safe}}theme{{page.resource_suffix}}.css\"> {# #}\n    {% endif %}\n    {% if !layout.favicon.is_empty() %}\n        <link rel=\"icon\" href=\"{{layout.favicon}}\"> {# #}\n    {% else %}\n        <link rel=\"alternate icon\" type=\"image/png\" {#+ #}\n            href=\"{{static_root_path|safe}}{{files.rust_favicon_png_32}}\"> {# #}\n        <link rel=\"icon\" type=\"image/svg+xml\" {#+ #}\n            href=\"{{static_root_path|safe}}{{files.rust_favicon_svg}}\"> {# #}\n    {% endif %}\n    {{ layout.external_html.in_header|safe }}\n</head> {# #}\n<body class=\"rustdoc {{+page.css_class}}\"> {# #}\n    <!--[if lte IE 11]> {# #}\n    <div class=\"warning\"> {# #}\n        This old browser is unsupported and will most likely display funky things. {# #}\n    </div> {# #}\n    <![endif]--> {# #}\n    {{ layout.external_html.before_content|safe }}\n    {% if page.css_class != \"src\" %}\n    <nav class=\"mobile-topbar\"> {# #}\n        <button class=\"sidebar-menu-toggle\" title=\"show sidebar\"></button> {# #}\n        {% if !layout.logo.is_empty() || page.rust_logo %}\n        <a class=\"logo-container\" href=\"{{page.root_path|safe}}{{display_krate_with_trailing_slash|safe}}index.html\"> {# #}\n        {% if page.rust_logo %}\n            <img class=\"rust-logo\" src=\"{{static_root_path|safe}}{{files.rust_logo_svg}}\" alt=\"\"> {# #}\n        {% else if !layout.logo.is_empty() %}\n            <img src=\"{{layout.logo}}\" alt=\"\"> {# #}\n        {% endif %}\n        </a> {# #}\n        {% endif %}\n    </nav>\n    {% endif %}\n    <nav class=\"sidebar\"> {# #}\n        {% if page.css_class != \"src\" %}\n        <div class=\"sidebar-crate\">\n            {% if !layout.logo.is_empty() || page.rust_logo %}\n            <a class=\"logo-container\" href=\"{{page.root_path|safe}}{{display_krate_with_trailing_slash|safe}}index.html\"> {# #}\n                {% if page.rust_logo %}\n                    <img class=\"rust-logo\" src=\"{{static_root_path|safe}}{{files.rust_logo_svg}}\" alt=\"logo\"> {# #}\n                {% else if !layout.logo.is_empty() %}\n                    <img src=\"{{layout.logo}}\" alt=\"logo\"> {# #}\n                {% endif %}\n            </a> {# #}\n            {% endif %}\n            <h2> {# #}\n                <a href=\"{{page.root_path|safe}}{{display_krate_with_trailing_slash|safe}}index.html\">{{display_krate}}</a> {# #}\n                {% if !display_krate_version_number.is_empty() %}\n                    <span class=\"version\">{{+ display_krate_version_number}}</span>\n                {% endif %}\n            </h2> {# #}\n        </div> {# #}\n        {% if !display_krate_version_extra.is_empty() %}\n        <div class=\"version\">{{+ display_krate_version_extra}}</div> {# #}\n        {% endif %}\n        {% else %}\n        <div class=\"src-sidebar-title\"> {# #}\n            <h2>Files</h2> {# #}\n        </div> {# #}\n        {% endif %}\n        {{ sidebar|safe }}\n    </nav> {# #}\n    <div class=\"sidebar-resizer\"></div> {# #}\n    <main> {# #}\n        {% if page.css_class != \"src\" %}<div class=\"width-limiter\">{% endif %}\n            {# defined in storage.js to avoid duplicating complex UI across every page #}\n            {# and because the search form only works if JS is enabled anyway #}\n            <rustdoc-search></rustdoc-search> {# #}\n            <section id=\"main-content\" class=\"content\">{{ content|safe }}</section> {# #}\n        {% if page.css_class != \"src\" %}</div>{% endif %}\n    </main> {# #}\n    {{ layout.external_html.after_content|safe }}\n</body> {# #}\n</html> {# #}\n"

I guess this is either an error in syntect (invalid use of regex?) or syntect-assets (supplying a broken language definition?). In either case, I don't know if we can do anything in here. Catching panics does not work well in Wasm. The error should be narrowed down and be reported upstream.

The broken editor state is saved and gets restored on every visit. As a fallback, when loading the page, the state should be wiped, and only be written again after setTimeout(…, 0), when it's know that the state is not broken.

@GuillaumeGomez
Copy link
Contributor

That'd be nice indeed.

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

Successfully merging a pull request may close this issue.

2 participants