Skip to content

concord.escape function img regex shouldn't be greedy #14

Open
@andrewshell

Description

@andrewshell

What I did:

I have an outline with html tags after an img tag. Ex: <img src="#" /><figcaption>Caption</figcaption>

What I expect to happen:

The &lt; and &gt; signs around figcaption should remain intact. Only the tags for img should be modified.

<img src="#" />&lt;figcaption&gt;Caption&lt;/figcaption&gt;

What happens:

The final &gt; sign around /figcaption is converted to > while the end &gt; of img remains intact.

<img src="#" /&gt;&lt;figcaption&gt;Caption&lt;/figcaption/>

The fix:

The regex on line 996 of concord.js
https://github.com/scripting/concord/blob/master/concord.js#L996

Should change from:
new RegExp("&lt;"+tag+"((?!&gt;).+)(/)?&gt;","gi")

to:

new RegExp("&lt;"+tag+"((?!&gt;).+?)(/)?&gt;","gi")

(see the ? after .+)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions