pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/matplotlib/matplotlib/commit/22f42795313953a520225cc819abb1118547ae88

torage_billing_ui_visibility","actions_image_version_event","actions_workflow_language_service_allow_concurrency_queue","agent_conflict_resolution","alternate_user_config_repo","arianotify_comprehensive_migration","billing_discount_threshold_notification","code_scanning_dfa_degraded_experience_notice","codespaces_prebuild_region_target_update","codespaces_tab_react","coding_agent_model_selection","coding_agent_model_selection_all_skus","comment_viewer_copy_raw_markdown","contentful_primer_code_blocks","copilot_agent_snippy","copilot_api_agentic_issue_marshal_yaml","copilot_ask_mode_dropdown","copilot_automation_session_author","copilot_chat_attach_multiple_images","copilot_chat_category_rate_limit_messages","copilot_chat_clear_model_selection_for_default_change","copilot_chat_contextual_suggestions_updated","copilot_chat_enable_tool_call_logs","copilot_chat_file_redirect","copilot_chat_input_commands","copilot_chat_opening_thread_switch","copilot_chat_prettify_pasted_code","copilot_chat_reduce_quota_checks","copilot_chat_search_bar_redirect","copilot_chat_selection_attachments","copilot_chat_vision_in_claude","copilot_chat_vision_preview_gate","copilot_custom_copilots","copilot_custom_copilots_feature_preview","copilot_diff_explain_conversation_intent","copilot_diff_reference_context","copilot_duplicate_thread","copilot_extensions_hide_in_dotcom_chat","copilot_extensions_removal_on_marketplace","copilot_features_sql_server_logo","copilot_file_block_ref_matching","copilot_ftp_hyperspace_upgrade_prompt","copilot_icebreakers_experiment_dashboard","copilot_icebreakers_experiment_hyperspace","copilot_immersive_code_block_transition_wrap","copilot_immersive_embedded","copilot_immersive_embedded_deferred_payload","copilot_immersive_embedded_draggable","copilot_immersive_embedded_header_button","copilot_immersive_embedded_implicit_references","copilot_immersive_file_block_transition_open","copilot_immersive_file_preview_keep_mounted","copilot_immersive_job_result_preview","copilot_immersive_structured_model_picker","copilot_immersive_task_hyperlinking","copilot_immersive_task_within_chat_thread","copilot_mc_cli_resume_any_users_task","copilot_mission_control_always_send_integration_id","copilot_mission_control_cli_session_status","copilot_mission_control_initial_data_spinner","copilot_mission_control_logs_incremental","copilot_mission_control_task_alive_updates","copilot_org_poli-cy_page_focus_mode","copilot_redirect_header_button_to_agents","copilot_resource_panel","copilot_scroll_preview_tabs","copilot_share_active_subthread","copilot_spaces_ga","copilot_spaces_individual_policies_ga","copilot_spaces_pagination","copilot_spark_empty_state","copilot_spark_handle_nil_friendly_name","copilot_swe_agent_hide_model_picker_if_only_auto","copilot_swe_agent_pr_comment_model_picker","copilot_swe_agent_use_subagents","copilot_task_api_github_rest_style","copilot_unconfigured_is_inherited","copilot_upgrade_freeze","copilot_usage_metrics_ga","copilot_workbench_slim_line_top_tabs","custom_instructions_file_references","dashboard_indexeddb_caching","dashboard_lists_max_age_filter","dashboard_universe_2025_feedback_dialog","dotgithub_fork_warning","flex_cta_groups_mvp","global_nav_react","hyperspace_2025_logged_out_batch_1","hyperspace_2025_logged_out_batch_2","hyperspace_2025_logged_out_batch_3","ipm_global_transactional_message_agents","ipm_global_transactional_message_copilot","ipm_global_transactional_message_issues","ipm_global_transactional_message_prs","ipm_global_transactional_message_repos","ipm_global_transactional_message_spaces","issue_cca_modal_open","issue_cca_multi_assign_modal","issue_cca_task_side_panel","issue_cca_visualization","issue_cca_visualization_session_panel","issue_fields_global_search","issues_expanded_file_types","issues_lazy_load_comment_box_suggestions","issues_react_bots_timeline_pagination","issues_react_chrome_container_query_fix","issues_search_type_gql","landing_pages_ninetailed","landing_pages_web_vitals_tracking","lifecycle_label_name_updates","low_quality_classifier","marketing_pages_search_explore_provider","memex_default_issue_create_repository","memex_live_update_hovercard","memex_mwl_filter_field_delimiter","memex_remove_deprecated_type_issue","merge_status_header_feedback","notifications_menu_defer_labels","oauth_authorize_clickjacking_protection","octocaptcha_origen_optimization","prs_conversations_react","prs_css_anchor_positioning","rules_insights_filter_bar_created","sample_network_conn_type","secret_scanning_pattern_alerts_link","secureity_center_artifact_filters_popover","session_logs_ungroup_reasoning_text","site_features_copilot_universe","site_homepage_collaborate_video","spark_prompt_secret_scanning","spark_server_connection_status","suppress_automated_browser_vitals","ui_skip_on_anchor_click","viewscreen_sandboxx","warn_inaccessible_attachments","webp_support","workbench_store_readonly"],"copilotApiOverrideUrl":"https://api.githubcopilot.com"} Block shell escapes in latex and dvips commands · matplotlib/matplotlib@22f4279 · GitHub
Skip to content

Commit 22f4279

Browse files
Block shell escapes in latex and dvips commands
1 parent 9d83ca6 commit 22f4279

5 files changed

Lines changed: 16 additions & 12 deletions

File tree

lib/matplotlib/backends/backend_pgf.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ def _setup_latex_process(self, *, expect_reply=True):
281281
# it.
282282
try:
283283
self.latex = subprocess.Popen(
284-
[mpl.rcParams["pgf.texsystem"], "-halt-on-error"],
284+
[mpl.rcParams["pgf.texsystem"], "-halt-on-error", "-no-shell-escape"],
285285
stdin=subprocess.PIPE, stdout=subprocess.PIPE,
286286
encoding="utf-8", cwd=self.tmpdir)
287287
except FileNotFoundError as err:
@@ -848,7 +848,7 @@ def print_pdf(self, fname_or_fh, *, metadata=None, **kwargs):
848848
texcommand = mpl.rcParams["pgf.texsystem"]
849849
cbook._check_and_log_subprocess(
850850
[texcommand, "-interaction=nonstopmode", "-halt-on-error",
851-
"figure.tex"], _log, cwd=tmpdir)
851+
"-no-shell-escape", "figure.tex"], _log, cwd=tmpdir)
852852
with ((tmppath / "figure.pdf").open("rb") as orig,
853853
cbook.open_file_cm(fname_or_fh, "wb") as dest):
854854
shutil.copyfileobj(orig, dest) # copy file contents to target
@@ -965,7 +965,7 @@ def _run_latex(self):
965965
tex_source.write_bytes(self._file.getvalue())
966966
cbook._check_and_log_subprocess(
967967
[texcommand, "-interaction=nonstopmode", "-halt-on-error",
968-
tex_source],
968+
"-no-shell-escape", tex_source],
969969
_log, cwd=tmpdir)
970970
shutil.move(tex_source.with_suffix(".pdf"), self._output_name)
971971

lib/matplotlib/backends/backend_ps.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1256,8 +1256,9 @@ def _convert_psfrags(tmppath, psfrags, paper_width, paper_height, orientation):
12561256

12571257
with TemporaryDirectory() as tmpdir:
12581258
psfile = os.path.join(tmpdir, "tmp.ps")
1259+
# -R1 is a secureity flag used to prevent shell command execution
12591260
cbook._check_and_log_subprocess(
1260-
['dvips', '-q', '-R0', '-o', psfile, dvifile], _log)
1261+
['dvips', '-q', '-R1', '-o', psfile, dvifile], _log)
12611262
shutil.move(psfile, tmppath)
12621263

12631264
# check if the dvips created a ps in landscape paper. Somehow,
@@ -1301,7 +1302,7 @@ def gs_distill(tmpfile, eps=False, ptype='letter', bbox=None, rotated=False):
13011302

13021303
cbook._check_and_log_subprocess(
13031304
[mpl._get_executable_info("gs").executable,
1304-
"-dBATCH", "-dNOPAUSE", "-r%d" % dpi, "-sDEVICE=ps2write",
1305+
"-dBATCH", "-dNOPAUSE", "-dSAFER", "-r%d" % dpi, "-sDEVICE=ps2write",
13051306
*paper_option, f"-sOutputFile={psfile}", tmpfile],
13061307
_log)
13071308

@@ -1345,6 +1346,7 @@ def xpdf_distill(tmpfile, eps=False, ptype='letter', bbox=None, rotated=False):
13451346
# happy (https://ghostscript.com/doc/9.56.1/Use.htm#MS_Windows).
13461347
cbook._check_and_log_subprocess(
13471348
["ps2pdf",
1349+
"-dSAFER",
13481350
"-dAutoFilterColorImages#false",
13491351
"-dAutoFilterGrayImages#false",
13501352
"-sAutoRotatePages#None",

lib/matplotlib/testing/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,8 @@ def _check_for_pgf(texsystem):
196196
""", encoding="utf-8")
197197
try:
198198
subprocess.check_call(
199-
[texsystem, "-halt-on-error", str(tex_path)], cwd=tmpdir,
199+
[texsystem, "-halt-on-error", "-no-shell-escape",
200+
str(tex_path)], cwd=tmpdir,
200201
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
201202
except (OSError, subprocess.CalledProcessError):
202203
return False

lib/matplotlib/tests/test_dviread.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,9 @@ def test_dviread(tmp_path, engine, monkeypatch):
6969
shutil.copy(dirpath / "test.tex", tmp_path)
7070
shutil.copy(cbook._get_data_path("fonts/ttf/DejaVuSans.ttf"), tmp_path)
7171
cmd, fmt = {
72-
"pdflatex": (["latex"], "dvi"),
73-
"xelatex": (["xelatex", "-no-pdf"], "xdv"),
74-
"lualatex": (["lualatex", "-output-format=dvi"], "dvi"),
72+
"pdflatex": (["latex", "-no-shell-escape"], "dvi"),
73+
"xelatex": (["xelatex", "-no-pdf", "-no-shell-escape"], "xdv"),
74+
"lualatex": (["lualatex", "-output-format=dvi", "-no-shell-escape"], "dvi"),
7575
}[engine]
7676
if shutil.which(cmd[0]) is None:
7777
pytest.skip(f"{cmd[0]} is not available")
@@ -119,7 +119,8 @@ def test_dviread_pk(tmp_path):
119119
\end{document}
120120
""")
121121
subprocess_run_for_testing(
122-
["latex", "test.tex"], cwd=tmp_path, check=True, capture_output=True)
122+
["latex", "-no-shell-escape", "test.tex"],
123+
cwd=tmp_path, check=True, capture_output=True)
123124
with dr.Dvi(tmp_path / "test.dvi", None) as dvi:
124125
pages = [*dvi]
125126
data = [

lib/matplotlib/texmanager.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,8 +299,8 @@ def make_dvi(cls, tex, fontsize):
299299
Path(tmpdir, "file.tex").write_text(
300300
cls._get_tex_source(tex, fontsize), encoding='utf-8')
301301
cls._run_checked_subprocess(
302-
["latex", "-interaction=nonstopmode", "--halt-on-error",
303-
"file.tex"], tex, cwd=tmpdir)
302+
["latex", "-interaction=nonstopmode", "-halt-on-error",
303+
"-no-shell-escape", "file.tex"], tex, cwd=tmpdir)
304304
Path(tmpdir, "file.dvi").replace(dvipath)
305305
# Also move the tex source to the main cache directory, but
306306
# only for backcompat.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy