Problem/Motivation

ZIP Export creates folders with title has an slash

Steps to reproduce

Create a node with a title that contains an Slash (/) in its name.
Generate an export, a subfolder is created.

Proposed resolution

Filenames generate scape special characters

CommentFileSizeAuthor
#5 content_first_bug.png81.76 KBeduardo morales alberti
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

gedur created an issue. See original summary.

gedur’s picture

Title: ZIP Export creates folders with title has an slash » ZIP Export creates folders when node title has an slash

eduardo morales alberti made their first commit to this issue’s fork.

eduardo morales alberti’s picture

Status: Active » Needs review
StatusFileSize
new81.76 KB

Ready!
Replace problematic chars by "-"
Fix content first


        $title = $this->transliteration->transliterate($node->label(), $node->language()->getId());
        // Replace forward slashes and other problematic characters in filename.
        $title = str_replace(['/', '\\'], '-', $title);
        $zip->addFromString($title . '.md', $rendered->getMarkdown());
      }
eduardo morales alberti’s picture

Using regex to avoid special chars in the file:

$title = preg_replace('/[^A-Za-z0-9_-]/', '-', $title);

eduardo morales alberti’s picture

Status: Needs review » Fixed

Fixed!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.