Skip to content

Commit

Permalink
Stricter matching for lang attributes
Browse files Browse the repository at this point in the history
Lang value now supports only chars legal in BCP-47 and underscore.

Fixes #76
  • Loading branch information
borgar committed Apr 21, 2021
1 parent 212a150 commit c402299
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/textile/attr.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const reColSpan = /^\\(\d+)/;
const reRowSpan = /^\/(\d+)/;
const reStyles = /^\{([^}]*)\}/;
const reCSS = /^\s*([^:\s]+)\s*:\s*(.+)\s*$/;
const reLang = /^\[([^[\]\n]+)\]/;
const reLang = /^\[([a-zA-Z0-9_-]+)\]/;

const pbaAlignLookup = {
'<': 'left',
Expand Down
7 changes: 7 additions & 0 deletions test/jstextile.js
Original file line number Diff line number Diff line change
Expand Up @@ -682,3 +682,10 @@ test('correct glyph convertion', t => {
'<p>foo &#8212; bar <em>foo foo -- bar bar</em> <code>foo -- bar</code></p>\nfoo -- bar');
t.end();
});


test('less liberal lang attr #76', t => {
t.is(textile.convert('%["red":https://example.com].%'),
'<p><span><a href="https://example.com">red</a>.</span></p>');
t.end();
});

0 comments on commit c402299

Please sign in to comment.