8000 Do not coerce layout paths in theme-gem to the source directory by ashmaroli · Pull Request #6603 · jekyll/jekyll · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Do not coerce layout paths in theme-gem to the source directory #6603

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jan 2, 2018

Conversation

ashmaroli
Copy link
Member
@ashmaroli ashmaroli commented Dec 6, 2017

Resolves #6241
Resolves #6332

Do not coerce layout paths in theme-gem to the source directory.

/cc @jekyll/build

@ashmaroli ashmaroli added the fix label Dec 6, 2017
@ashmaroli ashmaroli added this to the v3.7.0 milestone Dec 6, 2017
Scenario: A themed-site and incremental regeneration
Given I have a configuration file with "theme" set to "test-theme"
And I have an "index.md" page that contains "Themed site"
When I run jekyll build -IV
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you use the full flag names here for readability, --incremental, --verbose?

@@ -26,6 +26,7 @@ def regenerate?(document)
when Document
regenerate_document?(document)
else
return false if document.is_a?(String) && file_in_theme_dir?(document)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where do we call regenerate? with a String?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you debug right here using puts document.inspect calls, you'll see that some of the dependencies (on the first build with -I flag) are just regular paths to files in the theme-gem

@DirtyF
Copy link
Member
DirtyF commented Dec 7, 2017

I tried this branch with @mmistakes theme and the build time is way faster:

Before

Regeneration time is almost the same as the initial build time:

 Incremental build: enabled
      Generating...
                    done in 11.622 seconds.
 Auto-regeneration: enabled for '/Users/frank/code/jekyll/tests/minimal-mistakes/test'
    Server address: http://127.0.0.1:4000/test/
  Server running... press ctrl-c to stop.
      Regenerating: 1 file(s) changed at 2017-12-15 11:19:48
                    _portfolio/baz-boom-identity.md
                    ...done in 11.151307 seconds.

After

                    done in 14.231 seconds.
 Auto-regeneration: enabled for '/Users/frank/code/jekyll/tests/minimal-mistakes/test'
    Server address: http://127.0.0.1:4000/test/
  Server running... press ctrl-c to stop.
      Regenerating: 1 file(s) changed at 2017-12-15 11:22:22
                    _portfolio/baz-boom-identity.md
                    ...done in 2.390946 seconds.

@DirtyF DirtyF requested a review from a team December 15, 2017 10:29
@DirtyF
Copy link
Member
DirtyF commented Dec 15, 2017

CI Tests are passing, a quick benchmark shows a significant improvement (should benefit all jekyll-remote-themeusers), is there anything left blockin' this?

/cc @benbalter

benbalter
benbalter previously approved these changes Dec 15, 2017
DirtyF
DirtyF previously approved these changes Dec 15, 2017
@parkr parkr mentioned this pull request Dec 15, 2017
3 tasks
Copy link
Member
@mattr- mattr- left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking 👍. I have one small comment about security that could use an answer.

site.in_source_dir(document.path),
site.in_source_dir(layout.path)
)
site.regenerator.add_dependency(document.path, layout.path)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm worried that this change could introduce security issues because we're not being explicit about files being in the site's source directory. Do we have tests that indicate that document and layout objects can only exist within the sandbox that is a jekyll site?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with your concerns regarding security since this change removes the existing sanitization..
While document here refers to any renderable object (Jekyll::Document, Jekyll::Excerpt, Jekyll::Page, Jekyll::PageWithoutAFile) which can be manually created by a plugin and pushed into the site payload via the :pre_render hooks, this method here simply considers adding the concerned paths to the metadata file when required..

Layouts can exist both in the site.source and in site.theme.root elsewhere. So coercing a layout.path to be strictly within the site.source just here is not right.

if site.theme && site.theme.layouts_path.eql?(base)
@base_dir = site.theme.root
@path = site.in_theme_dir(base, name)
else
@base_dir = site.source
@path = site.in_source_dir(base, name)
end

I can coerce the document.path to be within the site.source and not affect this patch at all since the document.path is simply a key in the metadata hash..

while a layout object (a dependency) can point to a file within the source
directory or within the theme-gem, other renderable objects can be coerced
to within the source directory.
@ashmaroli ashmaroli force-pushed the no-regen-theme-files branch from 9274ed7 to 98993f9 Compare December 17, 2017 02:28
@ashmaroli ashmaroli changed the title Incremental option should not regenerate theme-gem files Incremental option should not regenerate theme-gem files [WIP] Dec 17, 2017
@ashmaroli ashmaroli changed the title Incremental option should not regenerate theme-gem files [WIP] Incremental option should not regenerate files that depend solely on files in the theme-gem Dec 17, 2017
@ashmaroli ashmaroli changed the title Incremental option should not regenerate files that depend solely on files in the theme-gem Do not coerce layout paths in theme-gem to the source directory Dec 17, 2017
@ashmaroli ashmaroli dismissed stale reviews from benbalter and DirtyF December 17, 2017 09:35

The patch changed considerably since last review

@DirtyF DirtyF removed the request for review from ayastreb December 17, 2017 13:00
@DirtyF DirtyF requested a review from a team December 17, 2017 13:00
Copy link
Member
@Crunch09 Crunch09 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@ghost
Copy link
ghost commented Jan 2, 2018

one more review for this, and we can ship it in 3.7.0!

@DirtyF
Copy link
Member
DirtyF commented Jan 2, 2018

@jekyllbot: merge +minor

@jekyllbot jekyllbot merged commit 3c959af into jekyll:master Jan 2, 2018
jekyllbot added a commit that referenced this pull request Jan 2, 2018
@ashmaroli ashmaroli deleted the no-regen-theme-files branch January 4, 2018 06:48
@jekyll jekyll locked and limited conversation to collaborators Jul 12, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

incremental build fails for very basic example For gem-based themes, an incremental build run always as FULL
7 participants
0