allow stylesheets to read and write files in the site directory#1951
allow stylesheets to read and write files in the site directory#1951xworld21 wants to merge 1 commit into
Conversation
2b54ca2 to
f7d837e
Compare
f7d837e to
ddc4d46
Compare
|
I have removed the libxslt security callback stuff, and kept this PR at a minimum: the point is, XSLT.pm is supposed to run in the site directory, because stylesheets can create additional files via The security callbacks will reappear in the |
|
High-level question to @brucemiller : should LaTeXML's XSLT framework use |
| my $destdir = $doc->getDestinationDirectory; | ||
| my $orig_cwd = pathname_cwd(); | ||
| pathname_chdir($destdir); | ||
|
|
||
| my $newdoc = $doc->new($$self{stylesheet}->transform($doc->getDocument, %params)); | ||
|
|
||
| pathname_chdir($orig_cwd); |
There was a problem hiding this comment.
I would also suggest a defensive check that the change is needed / well-defined:
| my $destdir = $doc->getDestinationDirectory; | |
| my $orig_cwd = pathname_cwd(); | |
| pathname_chdir($destdir); | |
| my $newdoc = $doc->new($$self{stylesheet}->transform($doc->getDocument, %params)); | |
| pathname_chdir($orig_cwd); | |
| my $destdir = $doc->getDestinationDirectory; | |
| my $orig_cwd = pathname_cwd(); | |
| my $needs_cwd_change = ($destdir ne $orig_cwd) && (-d $destdir); | |
| pathname_chdir($destdir) if $needs_cwd_change; | |
| my $newdoc = $doc->new($$self{stylesheet}->transform($doc->getDocument, %params)); | |
| pathname_chdir($orig_cwd) if $needs_cwd_change; |
There was a problem hiding this comment.
I suppose we should also canonicalise the paths (especially if mixed path separators are involved) and emit an error/fatal if chdir fail.
Since this PR is under attention again, I should clarify the intention here, and split @dginev's question into two parts:
|
Small functionality
& security improvement, while working on #1948: stylesheets can read (viadocument()) and write (via<exsl:document>) files. This PR ensures that read/write operations happen in the site directory.For security, operations are also restricted to the site directory, and network access is disabled.Edit: this fixes #2053 in so far as letting
exsl:document()write files in the correct place. My sandbox question in #2053 should rather be part of #2218.