jhamlet / svg-react-loader

Webpack SVG to React Component Loader
MIT License
559 stars 82 forks source link

Maximum call stack exceeded for badly formatted svgs #13

Closed 0x80 closed 8 years ago

0x80 commented 8 years ago

I imported the icon I downloaded from here. It has some empty svg groups appended to the source, which lead to the call stack error.

<?xml version="1.0" encoding="iso-8859-1"?>
<!-- Generator: Adobe Illustrator 16.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0)  -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
     width="432.544px" height="432.544px" viewBox="0 0 432.544 432.544" style="enable-background:new 0 0 432.544 432.544;"
     xml:space="preserve">
<g>
    <g>
        <path d="M0,313.775v118.77h118.771l237.541-237.541L237.539,76.232L0,313.775z M103.638,395.999L103.638,395.999l-30.55,0.004
            v-36.546H36.545v-30.553l25.981-25.981l67.093,67.092L103.638,395.999z M246.683,124.77c4.182,0,6.276,2.095,6.276,6.28
            c0,1.906-0.664,3.521-1.999,4.856L96.214,290.651c-1.333,1.328-2.952,1.995-4.854,1.995c-4.184,0-6.279-2.098-6.279-6.279
            c0-1.906,0.666-3.521,1.997-4.856l154.747-154.743C243.154,125.436,244.773,124.77,246.683,124.77z"/>
        <path d="M421.976,77.654l-67.091-66.806C347.653,3.619,338.992,0,328.903,0c-10.283,0-18.842,3.619-25.693,10.848l-47.394,47.109
            l118.773,118.77l47.394-47.392c7.042-7.043,10.561-15.608,10.561-25.697C432.54,93.743,429.022,85.08,421.976,77.654z"/>
    </g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
</svg>
RangeError: Maximum call stack size exceeded
    at keysIn (/Users/me/project/node_modules/lodash/object/keysIn.js:55:12)
    at /Users/me/project/node_modules/lodash/object/omit.js:39:47
    at /Users/me/project/node_modules/lodash/function/restParam.js:45:27
    at sanitize (/Users/me/project/node_modules/svg-react-loader/utility/sanitize.js:92:14)
    at /Users/me/project/node_modules/svg-react-loader/utility/sanitize.js:98:21
    at Array.forEach (native)
    at sanitize (/Users/me/project/node_modules/svg-react-loader/utility/sanitize.js:93:13)
    at /Users/me/project/node_modules/svg-react-loader/utility/sanitize.js:98:21
    at Array.forEach (native)
    at sanitize (/Users/me/project/node_modules/svg-react-loader/utility/sanitize.js:93:13)
    at /Users/me/project/node_modules/svg-react-loader/utility/sanitize.js:98:21
    at Array.forEach (native)
    at sanitize (/Users/me/project/node_modules/svg-react-loader/utility/sanitize.js:93:13)
    at /Users/me/project/node_modules/svg-react-loader/utility/sanitize.js:98:21
    at Array.forEach (native)
    at sanitize (/Users/me/project/node_modules/svg-react-loader/utility/sanitize.js:93:13)
jhamlet commented 8 years ago

This looks like v0.3.0

I can not reproduce the problem using the above svg and version 0.3.2 of svg-react-loader.

Try upgrading and see if that helps.

jhamlet commented 8 years ago

Closing as there has been no discussion on this in some time.