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

Some characters break shortcodes #249

Closed
NuLL3rr0r opened this issue Mar 9, 2018 · 5 comments
Closed

Some characters break shortcodes #249

NuLL3rr0r opened this issue Mar 9, 2018 · 5 comments
Labels
bug done in pr Already done in a PR

Comments

@NuLL3rr0r
Copy link

NuLL3rr0r commented Mar 9, 2018

Let's say I have a shortcode named quote:

<blockquote>
    <p>
        {{ body }}
    </p>

    -- {% if href %}<a href="{{ href }}">{% endif %}{{ author }}{% if href %}</a>{% endif %}
</blockquote>

If I call this short code like this:

{% quote(author="C++ Standard Core Language Defect Reports and Accepted Issues, Revision 82, delete and user-written deallocation function") %}
...if the value of the operand of delete is the null pointer the operation has no effect.
{% end %}

I'll get this on the terminal when I try to run Gutenberg:

thread '<unnamed>' panicked at 'index out of bounds: the len is 1 but the index is 1', /checkout/src/liballoc/vec.rs:1551:10
note: Run with `RUST_BACKTRACE=1` for a backtrace.

If I replace those commas, with something else or remove them it works. It seems it parses those commas as separators for other arguments or something like that.

Now, If I call my shortcode like this:

{% quote(author="C++ Standard Core Language Defect Reports and Accepted Issues; Revision 82; delete and user-written deallocation function", href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#348") %}
...if the value of the operand of delete is the null pointer the operation has no effect.
{% end %}

The generated html code is going to be like this:

<p>{% quote(author="C++ Standard Core Language Defect Reports and Accepted Issues; Revision 82; delete and user-written deallocation function", href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg</p><blockquote>
    <p>
    ...if the value of the operand of delete is the null pointer the operation has no effect.
    </p>

    -- <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#348">C++ Standard Core Language Defect Reports and Accepted Issues; Revision 82; delete and user-written deallocation function</a>
</blockquote>

Which obviously should not output the part before opening blockquote tag. It happens due to the underscore character in the url. If I change cwg_defects.html to cwgdefects.html for example, it works.

It has been tested with v0.3.2.

@Keats Keats added the bug label Mar 9, 2018
@Keats
Copy link
Collaborator

Keats commented Mar 9, 2018

That's a known issue (dup of #165). There is an ongoing rewrite of the markdown/shortcode renderer by @reillysiemens and @RadicalZephyr that should fix that for 0.4

I might fix the faulty regex in the next minor version at least though

@NuLL3rr0r
Copy link
Author

OK, thank you so much for the info. Is there any estimation on when 0.4 will be released?

@Keats
Copy link
Collaborator

Keats commented Mar 10, 2018

None, I'm not the one working on it.

@Keats
Copy link
Collaborator

Keats commented Mar 28, 2018

So the shortcode parse will now parse the arguments as expected in the next branch but it will still fail with markdown characters like _. I'm probably going to release 0.3.3 tomorrow and focus on the markdown issue right after as I consider that the problem number one in current Gutenberg.

@NuLL3rr0r
Copy link
Author

Great news! Thank you so much!

@Keats Keats mentioned this issue May 7, 2018
@Keats Keats added the done in pr Already done in a PR label May 11, 2018
@Keats Keats closed this as completed Aug 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug done in pr Already done in a PR
Projects
None yet
Development

No branches or pull requests

2 participants