Skip to content

Shapes SVG include PHP Parse Error #9693

@MarieComet

Description

@MarieComet

Prerequisites

  • [ x] I have searched for similar issues in both open and closed tickets and cannot find a duplicate.
  • [x ] The issue still exists against the latest stable version of Elementor.

Description

I've created a plugin which add custom SVG shapes to the section setting "Shape divider".

If the uploaded SVG file contain <?xml version="1.0" encoding="UTF-8"?>, PHP return a parse error : PHP Parse error: syntax error, unexpected 'version' (T_STRING)

It can be easily fixed by replacing include by echo file_get_contents in the print_shape_divider function (https://github.com/elementor/elementor/blob/master/includes/elements/section.php#L1533).

The XML declaration in the SVG file is important because of security reasons.

Steps to reproduce

Add a custom SVG shape, the SVG file must begin with <?xml version="1.0" encoding="UTF-8"?>
For example :
<?xml version="1.0" encoding="UTF-8"?> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 111.859 500 42.943"><path d="M.366 156.606h498.56v-45.71L.366 156.606z" fill="#bada55"></path></svg>

Isolating the problem

  • [x ] This bug happens with only Elementor plugin active (and Elementor Pro).
  • [x ] This bug happens with a default WordPress theme active.
  • [ x] I can reproduce this bug consistently using the steps above.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIndicates a bug with one or multiple components.element/settings/shape-dividerReferences the top and bottom element Shape Divider feature.status/mergedIndicates when a Pull Request has been merged to a Release.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions