Skip to content

Deprecated usage of RegExp.$1 etc. leads to problems with rhino engine (perhaps newer versions) #1041

@foto-andreas

Description

@foto-andreas

Hi,

after updating a lot of libraries in our project suddenly the following error encounters in showdownjs:

the code

List 1:
- e 11
- e 12

List2:
- e 21
- e 22

gives the following html code:

List 1:
<ul>
<li>e 11</li>
<li>e 12</li>
</ul>
List 2:
<ul>
<li>e 11</li>
<li>e 12</li>
</ul>

I tracked this town to the shadowjs code where ¨K1K and ¨K2K are replaced. The number is extracted with RegExp.$2, which is deprecated and seems to be broken (in rhino?). It delivers always "1" in the loop.

I think same problem has the ¨CnC unhashing.

The following code solves the problem for us:

// if this is a marker for a html block...
var re = /¨(K|G)(\d+)\1/;
var arr = null;
while ((arr = re.exec(grafsOutIt)) != null) {
	var delim = arr[1],
		num   = arr[2];

and in the C-Case:

var re = /¨C(\d+)C/;
var arr = null
while ((arr = re.exec(repText)) != null) {
	var num = arr[1];

Andreas

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions