Repository navigation
Open packages wrapped in a folder or nested in a ZIP, as eXeLearning does (#45) - #51
Merged
Merged
Conversation
…does ArchiveReader now finds the package the way eXeLearning's importer does. When there is no content.xml or contentv3.xml at the root, a single top-level folder is stripped from every name (macOS __MACOSX/ and ._* entries are ignored), and a ZIP whose only package is one .elp/.elpx at its root is copied out under the same limits and safety checks and read in its place, one level down at most. ELPParser, inspect(), the stream and contents constructors and extract() all go through it. More than one nested package is refused with a message that says so. Closes #45
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #51 +/- ##
=========================================
+ Coverage 92.6% 92.8% +0.1%
- Complexity 834 861 +27
=========================================
Files 29 29
Lines 2698 2767 +69
=========================================
+ Hits 2500 2568 +68
- Misses 198 199 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
…PUS_STRICTER check
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #45
Problem
eXeLearning's importer opens two shapes that elp-parser refused with
Invalid ELP file: No content XML found.: a ZIP whose entries all live under one folder (GitHub's "Download ZIP", a folder compressed with macOS Finder), and a ZIP whose only package is one.elp/.elpxat its root.Fix
ArchiveReaderfinds the package the way upstream does, only when there is nocontent.xmlorcontentv3.xmlat the root:__MACOSX/and._*entries are ignored, both when deciding and when listing or extracting..elp/.elpxat its root, it is copied to a temporary file throughextractEntry(), so under the same size limits and safety checks, and read in its place. This goes one level down at most (the inner package may itself be wrapped). The temporary file is removed when the reader goes away.UnsupportedFormatException("The ZIP holds more than one eXeLearning package: extract the one to open.").Everything goes through the reader, so
ELPParser::fromFile(),fromStream(),fromContents(),inspect(), entry reads and streaming,extract()and the archive hash all see the package itself. A regular package is not touched.Tests
tests/Unit/WrappedNestedPackageTest.php: wrapped (with__MACOSXentries), nested, nested-and-wrapped,fromContents(),inspect(),extract()without the folder, several packages refused, two levels refused, size limits still applied, and a regular package left alone. Three of its four tests failed before the change.tests/Unit/CorpusTest.php: the two corpus packages (edge/wrapped-in-folder,edge/nested-package) now open and match the expected pages and unused resources, and the "not opened yet" list is gone. WithELPX_TEST_CORPUSset: 4 passed (262 assertions).composer test: 99 passed (4 corpus tests skipped without the variable).composer lintandcomposer analyseclean.CHANGELOG.md(Unreleased → Added) anddocs/formats.mddescribe it.Left out
.zipfor a nested package), sogetPackageProfile()reportsode-…rather thanelpx-…for one.