metanorma / vectory

Convert between vector image formats (Ruby)
2 stars 0 forks source link

(URGENT) SvgMapping.build_svg_document crashes #39

Closed ronaldtse closed 6 months ago

ronaldtse commented 6 months ago

Crash:

    def build_svg_document(image)
      vector = build_vector(image)

      SvgDocument.new(vector.content)
    end

    def build_vector(image)
      return Vectory::Svg.from_content(image.to_xml) if image.name == "svg"

      return unless image.name == "image"

      src = image["src"]
      return Vectory::Datauri.new(src).to_vector if /^data:/.match?(src)

      path = @local_directory.empty? ? src : File.join(@local_directory, src)
      return unless File.exist?(path)

      Vectory::Svg.from_path(path)
    end

Notice that build_vector sometimes returns nil. This means that build_svg_document will crash because in vector.content, vector is nil.

ronaldtse commented 6 months ago

@alexeymorozov please also help add a spec to guard against this problem.

alexeymorozov commented 6 months ago

Yes.. 😕 Fixed with specs in #40 and released in v0.7.5

@opoudjis I took the initial xml and noticed that the fixture measure_schemaexpg5.svg is missing. Though vectory can handle it now, seems that this fixture is treated like it should exist. How is it important?

opoudjis commented 6 months ago

Given the chaos of ISO 10303, I can't reply to that without spending far more time on this than it deserves. If SVG files are not being generated in that repository, then it's that project's concern to find. Don't worry about it, you've addressed the issue of missing SVGs generically, and that's more important.