Skip to content

Commit

Permalink
[fc] Repository: Products.PortalTransforms
Browse files Browse the repository at this point in the history
Branch: refs/heads/master
Date: 2024-08-05T16:58:51+02:00
Author: Manuel Reinhardt (reinhardt) <reinhardt@syslab.com>
Commit: plone/Products.PortalTransforms@d5c91cf

feat: Shortcut in safe_html

Check for signs of html or script, skip further processing if none are found.
Saves processing time for lxml parsing and manipulation.

Files changed:
A news/66.feature
M Products/PortalTransforms/transforms/safe_html.py
Repository: Products.PortalTransforms

Branch: refs/heads/master
Date: 2024-08-05T23:33:38Z
Author: pre-commit-ci[bot] (pre-commit-ci[bot]) <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Commit: plone/Products.PortalTransforms@0bb7777

[pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

Files changed:
M Products/PortalTransforms/transforms/safe_html.py
Repository: Products.PortalTransforms

Branch: refs/heads/master
Date: 2024-08-05T18:35:24-07:00
Author: David Glick (davisagli) <david@glicksoftware.com>
Commit: plone/Products.PortalTransforms@85d7947

Merge pull request #66 from plone/scrub-shortcut

Shortcut in safe_html

Files changed:
A news/66.feature
M Products/PortalTransforms/transforms/safe_html.py
  • Loading branch information
davisagli committed Aug 6, 2024
1 parent 821ea8a commit 1e405ad
Showing 1 changed file with 51 additions and 51 deletions.
102 changes: 51 additions & 51 deletions last_commit.txt
Original file line number Diff line number Diff line change
@@ -1,54 +1,54 @@
Repository: plone.restapi


Branch: refs/heads/main
Date: 2024-08-05T12:01:03-07:00
Author: Steve Piercy (stevepiercy) <web@stevepiercy.com>
Commit: https://github.com/plone/plone.restapi/commit/602ccc6955eb066a989b24bfc0ac85b72da7cdc6

Clean up contributing docs and use RTD for pull request previews (#1798)

* Purge obsolete theme items and Netlify; Bump version

* Add pre-requisites and references to contributing to Plone in general

* Remove obsolete `make docs` and `bin/sphinxbuilder`

* Simplify Contributing

* news

* Purge Netlify

* Add RTD pull request preview workflow

* Use RTD to build docs and pull request previews

* Fix project slug

* Attempt to trigger RTD PR preview

* Override docutils pin from Zope

* Attempt to get all tests to pass with a special config for Plone 6 on Python 3.8

* Compare against `origin/main`

* Remove Python 3.7 section
Repository: Products.PortalTransforms


Branch: refs/heads/master
Date: 2024-08-05T16:58:51+02:00
Author: Manuel Reinhardt (reinhardt) <reinhardt@syslab.com>
Commit: https://github.com/plone/Products.PortalTransforms/commit/d5c91cfbd96dd5ca83c7c9e1d6ad502ef95e107f

feat: Shortcut in safe_html

Check for signs of html or script, skip further processing if none are found.
Saves processing time for lxml parsing and manipulation.

Files changed:
A .github/workflows/rtd-pr-preview.yml
A news/1798.documentation
A plone-6.0.x-python3.8.cfg
M .github/workflows/tests.yml
M .readthedocs.yaml
M Makefile
M docs/source/conf.py
M docs/source/contributing/index.md
M plone-6.0.x.cfg
M plone-6.1.x.cfg
D docs/requirements.txt
D netlify.toml

b'diff --git a/.github/workflows/rtd-pr-preview.yml b/.github/workflows/rtd-pr-preview.yml\nnew file mode 100644\nindex 0000000000..28e329ecf6\n--- /dev/null\n+++ b/.github/workflows/rtd-pr-preview.yml\n@@ -0,0 +1,22 @@\n+# .github/workflows/rtd-pr-preview.yml\n+name: readthedocs/actions\n+on:\n+ pull_request_target:\n+ types:\n+ - opened\n+ # Execute this action only on PRs that touch\n+ # documentation files.\n+ # paths:\n+ # - "docs/**"\n+\n+permissions:\n+ pull-requests: write\n+\n+jobs:\n+ documentation-links:\n+ runs-on: ubuntu-latest\n+ steps:\n+ - uses: readthedocs/actions/preview@v1\n+ with:\n+ project-slug: "plonerestapi"\n+ single-version: "true"\ndiff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml\nindex b93241b9dd..b354a9e4d5 100644\n--- a/.github/workflows/tests.yml\n+++ b/.github/workflows/tests.yml\n@@ -54,7 +54,7 @@ jobs:\n \n # buildout\n - name: buildout\n- run: buildout -t 10 -c plone-${{ matrix.plone-version }}.x.cfg\n+ run: if [ "${{ matrix.plone-version }}" == "6.0" ] && [ ${{ matrix.python-version }} == \'3.8\' ]; then buildout -t 10 -c plone-6.0.x-python3.8.cfg; else buildout -t 10 -c plone-${{ matrix.plone-version }}.x.cfg; fi;\n env:\n CI: true\n \ndiff --git a/.readthedocs.yaml b/.readthedocs.yaml\nindex deeaa762f7..0bf1b9ba85 100644\n--- a/.readthedocs.yaml\n+++ b/.readthedocs.yaml\n@@ -5,25 +5,21 @@\n # Required\n version: 2\n \n-# Set the version of Python and other tools you might need\n+# Set the OS, Python version and other tools you might need\n build:\n- os: ubuntu-20.04\n+ os: ubuntu-22.04\n tools:\n- python: "3.9"\n- # You can also specify other tool versions:\n- # nodejs: "16"\n- # rust: "1.55"\n- # golang: "1.17"\n-\n-# Build documentation in the docs/ directory with Sphinx\n-sphinx:\n- configuration: docs/source/conf.py\n-\n-# If using Sphinx, optionally build your docs in additional formats such as PDF\n-# formats:\n-# - pdf\n-\n-# Optionally declare the Python requirements required to build your docs\n-python:\n- install:\n- - requirements: requirements-docs.txt\n+ python: "3.12"\n+ commands:\n+ # Cancel building pull requests when there aren\'t changes in the docs directory or YAML file.\n+ # You can add any other files or directories that you\'d like here as well,\n+ # like your docs requirements file, or other files that will change your docs build.\n+ #\n+ # If there are no changes (git diff exits with 0) we force the command to return with 183.\n+ # This is a special exit code on Read the Docs that will cancel the build immediately.\n+ - |\n+ if [ "$READTHEDOCS_VERSION_TYPE" = "external" ] && git diff --quiet origin/main -- docs/ .readthedocs.yaml requirements-docs.txt requirements.txt;\n+ then\n+ exit 183;\n+ fi\n+ - make rtd-pr-preview\ndiff --git a/Makefile b/Makefile\nindex eb379c7b74..71c500930e 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -95,10 +95,6 @@ black: ## Black\n zpretty: ## zpretty\n \tif [ -f "bin/zpretty" ]; then zpretty -i ./**/*.zcml; fi\n \n-.PHONY: Build Docs\n-docs: ## Build Docs\n-\tbin/sphinxbuilder\n-\n .PHONY: docs-clean\n docs-clean: ## Clean current and legacy docs build directories, and Python virtual environment\n \tcd $(DOCS_DIR) && rm -rf $(BUILDDIR)/\n@@ -138,10 +134,11 @@ docs-vale: ## Run Vale style, grammar, and spell checks\n \t@echo\n \t@echo "Vale is finished; look for any errors in the above output."\n \n-.PHONY: netlify\n-netlify:\n+.PHONY: rtd-pr-preview\n+rtd-pr-preview: ## Build pull request preview on Read the Docs\n+\tpip install -r requirements.txt\n \tpip install -r requirements-docs.txt\n-\tcd $(DOCS_DIR) && sphinx-build -b html $(ALLSPHINXOPTS) ../$(BUILDDIR)/html\n+\tcd $(DOCS_DIR) && sphinx-build -b html $(ALLSPHINXOPTS) ${READTHEDOCS_OUTPUT}/html/\n \n .PHONY: Test Release\n test-release: ## Run Pyroma and Check Manifest\ndiff --git a/docs/requirements.txt b/docs/requirements.txt\ndeleted file mode 100644\nindex 82f259eacf..0000000000\n--- a/docs/requirements.txt\n+++ /dev/null\n@@ -1,2 +0,0 @@\n-sphinxcontrib.httpdomain\n-sphinxcontrib.httpexample\n\\ No newline at end of file\ndiff --git a/docs/source/conf.py b/docs/source/conf.py\nindex d8e125b8f4..c1cb7ad6f7 100644\n--- a/docs/source/conf.py\n+++ b/docs/source/conf.py\n@@ -34,7 +34,7 @@\n # built documents.\n # TODO: There must be a way to import this from `setup.py` so we don\'t have to\n # update it manually for each release.\n-version = "8.24.2.dev0"\n+version = "9.7.2.dev0"\n release = version\n \n # -- General configuration ----------------------------------------------------\n@@ -176,15 +176,7 @@ def patch_pygments_to_highlight_jsonschema():\n "use_repository_button": True,\n "use_issues_button": True,\n "use_edit_page_button": True,\n- "extra_navbar": """\n- <p class="ploneorglink">\n- <a href="https://plone.org">\n- <img src="/_static/logo.svg" alt="plone.org" /> plone.org</a>\n- </p>""",\n- "extra_footer": """<p>The text and illustrations in this website are licensed by the Plone Foundation under a Creative Commons Attribution 4.0 International license. Plone and the Plone\xc2\xae logo are registered trademarks of the Plone Foundation, registered in the United States and other countries. For guidelines on the permitted uses of the Plone trademarks, see <a href="https://plone.org/foundation/logo">https://plone.org/foundation/logo</a>. All other trademarks are owned by their respective owners.</p>\n- <p><a href="https://www.netlify.com">\n- <img src="https://www.netlify.com/img/global/badges/netlify-color-bg.svg" alt="Deploys by Netlify" />\n-</a></p>""",\n+ "extra_footer": """<p>The text and illustrations in this website are licensed by the Plone Foundation under a Creative Commons Attribution 4.0 International license. Plone and the Plone\xc2\xae logo are registered trademarks of the Plone Foundation, registered in the United States and other countries. For guidelines on the permitted uses of the Plone trademarks, see <a href="https://plone.org/foundation/logo">https://plone.org/foundation/logo</a>. All other trademarks are owned by their respective owners.</p>""",\n }\n \n # Theme options are theme-specific and customize the look and feel of a theme\ndiff --git a/docs/source/contributing/index.md b/docs/source/contributing/index.md\nindex 5654a396d4..1c0c9ac617 100644\n--- a/docs/source/contributing/index.md\n+++ b/docs/source/contributing/index.md\n@@ -1,13 +1,24 @@\n ---\n myst:\n html_meta:\n- "description": "Contributing to plone.restapi"\n- "property=og:description": "Contributing to plone.restapi"\n- "property=og:title": "Contributing to plone.restapi"\n- "keywords": "Plone, plone.restapi, REST, API, Contributing, documentation"\n+ "description": "Contribute to plone.restapi"\n+ "property=og:description": "Contribute to plone.restapi"\n+ "property=og:title": "Contribute to plone.restapi"\n+ "keywords": "Plone, plone.restapi, REST, API, contribute, documentation"\n ---\n \n-# Contributing to `plone.restapi`\n+# Contribute to `plone.restapi`\n+\n+This section describes how to contribute to the `plone.restapi` project.\n+It extends {doc}`plone:contributing/index`.\n+\n+\n+## Pre-requisites\n+\n+Prepare your system by installing {ref}`plone:plone-pre-requisites-label`.\n+\n+\n+## Set up development environment\n \n We use GNU `make` when developing `plone.restapi`.\n To install this package, its dependencies, and its documentation, code formatting, and testing tools, run the following command in the root of the project.\n@@ -16,21 +27,27 @@ To install this package, its dependencies, and its documentation, code formattin\n make\n ```\n \n-## Generating documentation examples\n+To see all the Makefile targets and help, use the following command.\n+\n+```shell\n+make help\n+```\n+\n+\n+## Generate documentation examples\n \n-This documentation includes examples of requests and responses (http, curl, httpie, and python-requests).\n+This documentation includes examples of requests and responses, using each of http, curl, httpie, and python-requests.\n These examples are generated by the documentation tests in `test_documentation.py`.\n-To generate a new example, add a new test case to `test_documentation.py`, for example `test_documentation_search_fullobjects`, and run the test\n+To generate a new example, add a new test case to `test_documentation.py`, for example `test_documentation_search_fullobjects`, and run the test.\n \n ```shell\n ./bin/test -t test_documentation_search_fullobjects\n ```\n \n-This generates the request and the response files in `tests/http-examples/`.\n+The above command also generates the request and the response files in `tests/http-examples/`.\n+Include them in the documentation using MyST syntax.\n \n-Include them in the documentation using MyST syntax:\n-\n-````\n+````markdown\n ```{eval-rst}\n .. http:example:: curl httpie python-requests\n :request: ../../src/plone/restapi/tests/http-examples/search_fullobjects.req\n@@ -40,31 +57,14 @@ Include them in the documentation using MyST syntax:\n ```\n ````\n \n-Build the documentation locally to test the rendering by running `./bin/sphinxbuilder`.\n-Alternatively, you can use Makefile targets:\n-\n-`docs-clean`\n-: Clean current and legacy docs build directories, and Python virtual environment\n-\n-`docs-html`\n-: Build HTML\n-\n-`docs-linkcheck`\n-: Run linkcheck\n-\n-`docs-linkcheckbroken`\n-: Run linkcheck and show only broken links\n+Build the documentation locally to test the rendering.\n \n-`docs-livehtml`\n-: Rebuild Sphinx documentation on changes, with live-reload in the browser\n-\n-`docs-vale`\n-: Run spell, grammar, and style checks\n+```shell\n+make docs-html\n+```\n \n-`docs`\n-: Build Docs\n+Add and commit the generated files in `src/plone/restapi/tests/http-examples/`.\n \n-Make sure you add and commit the generated files in `http-examples`.\n \n ## Conventions\n \n@@ -76,18 +76,18 @@ conventions\n \n ## Code formatting and testing\n \n-To ensure consistent code formatting, we use [Black](https://black.readthedocs.io/en/stable/index.html).\n-All pull requests must pass code formatting checks.\n-We recommend that you run Black locally.\n-You can use the following command to automatically format the code.\n+All changes must pass code formatting and tests.\n+Run these checks locally before creating a pull request.\n+\n+Use the following command to automatically format the code with [Black](https://black.readthedocs.io/en/stable/index.html).\n \n ```shell\n make black\n ```\n \n-To run tests locally and ensure your changes don\'t introduce any issues, use the following command.\n-This will execute the test suite and provide test feedback.\n+Use the following command to run tests.\n \n ```shell\n make test\n ```\n+\ndiff --git a/netlify.toml b/netlify.toml\ndeleted file mode 100644\nindex 9d440d0eb9..0000000000\n--- a/netlify.toml\n+++ /dev/null\n@@ -1,5 +0,0 @@\n-[build.environment]\n- PYTHON_VERSION = "3.8"\n-\n-[build]\n- ignore = "git diff --quiet $CACHED_COMMIT_REF $COMMIT_REF ./docs/"\ndiff --git a/news/1798.documentation b/news/1798.documentation\nnew file mode 100644\nindex 0000000000..b56db95533\n--- /dev/null\n+++ b/news/1798.documentation\n@@ -0,0 +1 @@\n+Update contributing docs for Plone 6, and switch from Netlify to Read the Docs for pull request previews. @stevepiercy\ndiff --git a/plone-6.0.x-python3.8.cfg b/plone-6.0.x-python3.8.cfg\nnew file mode 100644\nindex 0000000000..9fca1a2f0e\n--- /dev/null\n+++ b/plone-6.0.x-python3.8.cfg\n@@ -0,0 +1,17 @@\n+[buildout]\n+extends =\n+ https://dist.plone.org/release/6.0.11.1/versions.cfg\n+ base.cfg\n+\n+[instance]\n+recipe = plone.recipe.zope2instance\n+zodb-temporary-storage = off\n+\n+[versions]\n+pygments = 2.14.0\n+plone.app.linkintegrity = 4.0.3\n+robotframework-browser = 17.5.2\n+robotframework-assertion-engine = 2.0.0\n+robotframework-debuglibrary = 2.3.0\n+robotframework-pythonlibcore = 4.2.0\n+grpcio-tools = 1.59.0\ndiff --git a/plone-6.0.x.cfg b/plone-6.0.x.cfg\nindex 5c418ddfe0..5172c9ddaf 100644\n--- a/plone-6.0.x.cfg\n+++ b/plone-6.0.x.cfg\n@@ -13,6 +13,8 @@ recipe = plone.recipe.zope2instance\n zodb-temporary-storage = off\n \n [versions]\n+# Override pin from Zope. https://github.com/zopefoundation/Zope/issues/1220\n+docutils = 0.21.2\n pygments = 2.14.0\n plone.app.linkintegrity = 4.0.3\n robotframework-browser = 17.5.2\ndiff --git a/plone-6.1.x.cfg b/plone-6.1.x.cfg\nindex 2ac1f2b5af..54716fa951 100644\n--- a/plone-6.1.x.cfg\n+++ b/plone-6.1.x.cfg\n@@ -12,4 +12,6 @@ parts =\n recipe = plone.recipe.zope2instance\n zodb-temporary-storage = off\n \n-[versions]\n\\ No newline at end of file\n+[versions]\n+# Override pin from Zope. https://github.com/zopefoundation/Zope/issues/1220\n+docutils = 0.21.2\n'
A news/66.feature
M Products/PortalTransforms/transforms/safe_html.py

b'diff --git a/Products/PortalTransforms/transforms/safe_html.py b/Products/PortalTransforms/transforms/safe_html.py\nindex 787e7e1..fc25179 100644\n--- a/Products/PortalTransforms/transforms/safe_html.py\n+++ b/Products/PortalTransforms/transforms/safe_html.py\n@@ -4,6 +4,7 @@\n from lxml_html_clean import Cleaner\n from plone.base.interfaces import IFilterSchema\n from plone.base.utils import safe_bytes\n+from plone.base.utils import safe_text\n from plone.registry.interfaces import IRegistry\n from Products.PortalTransforms.interfaces import ITransform\n from Products.PortalTransforms.libtransforms.utils import bodyfinder\n@@ -183,6 +184,14 @@ def cleaner_options(self):\n return options\n \n def scrub_html(self, orig):\n+ orig_text = safe_text(orig)\n+ # short cut if no html or script is detected\n+ if not orig or not (\n+ hasScript(orig_text)\n+ or "<" in orig_text\n+ or any((entity in orig_text for entity in html5entities.values()))\n+ ):\n+ return orig_text\n # append html tag to create a dummy parent for the tree\n html_parser = html.HTMLParser(encoding="utf-8")\n orig = safe_bytes(orig)\ndiff --git a/news/66.feature b/news/66.feature\nnew file mode 100644\nindex 0000000..c07a4bb\n--- /dev/null\n+++ b/news/66.feature\n@@ -0,0 +1 @@\n+Shortcut in safe_html: Check for signs of html or script, skip further processing if none are found.\n'

Repository: Products.PortalTransforms


Branch: refs/heads/master
Date: 2024-08-05T23:33:38Z
Author: pre-commit-ci[bot] (pre-commit-ci[bot]) <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Commit: https://github.com/plone/Products.PortalTransforms/commit/0bb777712e109418f36174158d9815140aae2e73

[pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

Files changed:
M Products/PortalTransforms/transforms/safe_html.py

b'diff --git a/Products/PortalTransforms/transforms/safe_html.py b/Products/PortalTransforms/transforms/safe_html.py\nindex fc25179..934c529 100644\n--- a/Products/PortalTransforms/transforms/safe_html.py\n+++ b/Products/PortalTransforms/transforms/safe_html.py\n@@ -189,7 +189,7 @@ def scrub_html(self, orig):\n if not orig or not (\n hasScript(orig_text)\n or "<" in orig_text\n- or any((entity in orig_text for entity in html5entities.values()))\n+ or any(entity in orig_text for entity in html5entities.values())\n ):\n return orig_text\n # append html tag to create a dummy parent for the tree\n'

Repository: Products.PortalTransforms


Branch: refs/heads/master
Date: 2024-08-05T18:35:24-07:00
Author: David Glick (davisagli) <david@glicksoftware.com>
Commit: https://github.com/plone/Products.PortalTransforms/commit/85d7947fb25e942817663f6fbe9833cee35dd77c

Merge pull request #66 from plone/scrub-shortcut

Shortcut in safe_html

Files changed:
A news/66.feature
M Products/PortalTransforms/transforms/safe_html.py

b'diff --git a/Products/PortalTransforms/transforms/safe_html.py b/Products/PortalTransforms/transforms/safe_html.py\nindex 787e7e1..934c529 100644\n--- a/Products/PortalTransforms/transforms/safe_html.py\n+++ b/Products/PortalTransforms/transforms/safe_html.py\n@@ -4,6 +4,7 @@\n from lxml_html_clean import Cleaner\n from plone.base.interfaces import IFilterSchema\n from plone.base.utils import safe_bytes\n+from plone.base.utils import safe_text\n from plone.registry.interfaces import IRegistry\n from Products.PortalTransforms.interfaces import ITransform\n from Products.PortalTransforms.libtransforms.utils import bodyfinder\n@@ -183,6 +184,14 @@ def cleaner_options(self):\n return options\n \n def scrub_html(self, orig):\n+ orig_text = safe_text(orig)\n+ # short cut if no html or script is detected\n+ if not orig or not (\n+ hasScript(orig_text)\n+ or "<" in orig_text\n+ or any(entity in orig_text for entity in html5entities.values())\n+ ):\n+ return orig_text\n # append html tag to create a dummy parent for the tree\n html_parser = html.HTMLParser(encoding="utf-8")\n orig = safe_bytes(orig)\ndiff --git a/news/66.feature b/news/66.feature\nnew file mode 100644\nindex 0000000..c07a4bb\n--- /dev/null\n+++ b/news/66.feature\n@@ -0,0 +1 @@\n+Shortcut in safe_html: Check for signs of html or script, skip further processing if none are found.\n'

0 comments on commit 1e405ad

Please sign in to comment.