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

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

Open
andrewshell opened this issue Nov 19, 2020 · 0 comments
Open

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

andrewshell opened this issue Nov 19, 2020 · 0 comments

Comments

@andrewshell
Copy link

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 .+)

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

No branches or pull requests

1 participant