Closed foretix closed 6 years ago
To temporarily fix the problem I replaced uniqid()
with random_int(1, 10000000)
in https://github.com/SemanticMediaWiki/Mermaid/blob/master/src/MermaidParserFunction.php#L54 because uniqid() does not generate cryptographically secure values.
DIV elements are assigned the same ID, and thus it fails for the other elements.
This shouldn't happen as we explicitly use [0] to generate different IDs and as far as I remember we need IDs due to how the mermeid js interface works.
I'm bit surprised that you get the same ID for different #mermaid calls, so to increase entropy adding something like should help:
@@ -85,10 +85,13 @@ class MermaidParserFunction {
}
}
$content = isset( $params[0] ) ? $params[0] : '';
+ // #12
+ $id .= '-' . md5( $content );
[0] https://github.com/SemanticMediaWiki/Mermaid/blob/master/src/MermaidParserFunction.php#L54
On 2/8/18, Jaroslav Koblizek notifications@github.com wrote:
Setup and configuration
- Mermaid version: 1.0.0
- MediaWiki version: 1.30
- PHP version: 7.1.14
- Database system (MySQL, PostgresQL, etc.) and version: SQLite
Issue
When {{#mermaid:***}} function is used multiple times on one page, only the first diagram is generated, the others not.
{{#mermaid:graph LR Prague --> {{!}}travel by train{{!}}Brno }} {{#mermaid:graph LR Prague --> {{!}}travel by bus{{!}}Brno }} {{#mermaid:graph LR Prague --> {{!}}travel by car{{!}}Brno }}
...generates this output...
Reason
DIV elements are assigned the same ID, and thus it fails for the other elements.
-- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/SemanticMediaWiki/Mermaid/issues/12
To temporarily fix the problem I replaced
uniqid()
withrandom_int(1, 10000000)
in
That would work, or setting uniqid('', true)
should help as well.
On 2/8/18, Jaroslav Koblizek notifications@github.com wrote:
To temporarily fix the problem I replaced
uniqid()
withrandom_int(1, 10000000)
in https://github.com/SemanticMediaWiki/Mermaid/blob/master/src/MermaidParserFunction.php#L54 because uniqid() does not generate cryptographically secure values.-- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/SemanticMediaWiki/Mermaid/issues/12#issuecomment-364038283
Hmm, I added the "non-functional" example to the sandbox and it renders all three diagrams fine. We wiki is however on PHP 7.0 instead of PHP 7.1 as reported. However make the system even more solid is always preferable.
I forgot to mention one technical thing that I'm running PHP on Windows Server. Later, I'll try to test it on another Windows machine, and also with PHP 7.0. Let you know.
To let you know about my test with uniqid()
without parameters.
I tried making a test on another machine (Windows 10 with IIS 10 and PHP 7.1.14) and there it is ok. The issue appears just on Windows Server 2008 R2 with IIS 7.5 and PHP 7.1.14.
Setup and configuration
Issue
When
{{#mermaid:***}}
function is used multiple times on one page, only the first diagram is generated, the others not....generates this output...
Reason
DIV elements are assigned the same ID, and thus it fails for the other elements.