-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
# Arise v1.1.0 --- ## Changelog - Bumped `actions/checkout@v2` to `actions/checkout@v4`. No impact from this change. - Removed `sed` from the metadata tag evaluation in `build_header`. Replaced with Bash native pattern matching so that this evaluation is safer. - Added checks to automatically rewrite any XML reserved characters (&<>'") as their escape codes when present in page metadata (title, author, etc). - Rewrote the way a majority of the page metadata values are parsed in `get_page_metadata` to make the parsing more robust. This was necessary because previously unescaped double quotes (`"`) would break the parser. The workaround was to use escape codes, but if we're automatically parsing escape codes then we need a way to put these characters in unescaped now. - Added a CI test suite to build the default site and test to make sure that the XML reserved characters are getting properly escaped. This is helpful because it allows me to more continuously ensure that commits I make in dev don't break the site. - Added a Smart Deploy step in the deployment workflow to check whether the triggering branch is `main` or not so that CICD can intelligently deploy the site to either production or staging depending on what branch triggered the deployment.
- Loading branch information
1 parent
a954e82
commit ee6414e
Showing
13 changed files
with
260 additions
and
61 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# .github/workflows/ci-xml-reserved-characters.yml | ||
name: CI Test - XML Reserved Character Metadata Sanitisation | ||
|
||
on: | ||
# Runs on everything except the main branch since this is only a concern for dev. | ||
push: | ||
branches: | ||
- '**' | ||
- '!main' | ||
|
||
# Allows you to run this workflow manually from the Actions tab | ||
workflow_dispatch: | ||
|
||
# Allow one concurrent deployment | ||
concurrency: | ||
group: "xml-reserved-characters" | ||
cancel-in-progress: true | ||
|
||
# Default to bash | ||
defaults: | ||
run: | ||
shell: bash | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
name: Check XML Sanitisation | ||
steps: | ||
- name: git-checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Install pandoc | ||
run: sudo apt-get install -y pandoc | ||
|
||
- name: Build Arise | ||
run: bash arise build | ||
|
||
- name: Run test suite | ||
run: bash ci/xml-reserved-characters.sh |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<!-- BEGIN ARISE ------------------------------ | ||
Title:: "CI Test Suite - XML Reserved Characters & < > ' "" | ||
Author:: "Spectra Secure & < > ' "" | ||
Description:: "This post tests if we are properly filtering XML reserved characters in page metadata & < > ' "" | ||
Language:: "en" | ||
Thumbnail:: "kanagawa.jpg" | ||
Published Date:: "2023-11-08" | ||
Modified Date:: "2023011-08" | ||
---- END ARISE \\ DO NOT MODIFY THIS LINE ----> | ||
|
||
# CI Test Suite - XML Reserved Characters | ||
|
||
This page is part of a test suite to ensure that when a user tries to stick XML reserved characters into page metadata, such characters are properly converted to escape characters. This way we ensure that such characters don't break the monolithic sitemap or RSS feed. | ||
|
||
The way we do this is by having a test page in our template site which contains a post whose title, author, and destripction all contain the XML reserved characters (&<>'"). This test suite verifies that this output page has all of the reserved characters properly sanitised to the escape code versions, so that they're safe to handle within the site's XML sitemap and RSS feed. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
#!/bin/bash | ||
testpage='arise-out/posts/ci-xml-reserved-characters/index.html' | ||
|
||
echo "Arise CI - XML Reserved Character Sanitisation" | ||
echo "==============================================" | ||
echo "This is a test suite to ensure that when a user tries to stick XML reserved characters into page metadata, such characters are properly converted to escape characters. This ensures that such characters don't break the monolithic sitemap or RSS feed." | ||
echo "" | ||
echo "The way we do this is by having a test page in our template site (""$testpage"") which contains a post whose title, author, and destripction all contain the XML reserved characters (&<>'"'"'"). This test suite verifies that the output page has all of the reserved characters properly sanitised to the escape code versions, so that they're safe to handle within the site's XML sitemap and RSS feed." | ||
echo "" | ||
echo "" | ||
|
||
echo "Testing to ensure the Arise site built the test suite page..." | ||
if [ -f $testpage ] | ||
then | ||
echo "SUCCESS!" | ||
else | ||
echo "FAILED. No page was found where the test post is supposed to exist." | ||
echo " - Check that you haven't moved the test post located in arise-source/posts somewhere else" | ||
echo " - Check that you haven't broken Arise entirely" | ||
echo "Good luck, choom!" | ||
exit 1 | ||
fi | ||
echo "" | ||
|
||
echo "Testing to ensure that the title is rendering as it should..." | ||
titletest="<title>CI Test Suite - XML Reserved Characters & < > ' "" | ||
if [[ $(grep "$titletest" $testpage) ]] | ||
then | ||
echo "SUCCESS!" | ||
else | ||
echo "FAILED. The page title we were looking for did not render properly." | ||
echo "" | ||
echo "Pattern we were trying to match:" | ||
echo "$titletest" | ||
echo "===========" | ||
echo "Full line that contains a discrepancy:" | ||
echo "$(grep '<title>' $testpage | head -1)" | ||
exit 1 | ||
fi | ||
echo "" | ||
|
||
echo "Testing to ensure that the author is rendering as they should..." | ||
authortest='<meta name="author" content="Spectra Secure & < > ' "">' | ||
if [[ $(grep "$authortest" $testpage) ]] | ||
then | ||
echo "SUCCESS!" | ||
else | ||
echo "FAILED. The page author line we were looking for did not render properly." | ||
echo "" | ||
echo "Pattern we were trying to match:" | ||
echo "$authortest" | ||
echo "===========" | ||
echo "Full line that contains a discrepancy:" | ||
echo "$(grep '<meta name="author"' $testpage | head -1)" | ||
exit 1 | ||
fi | ||
echo "" | ||
|
||
echo "Testing to ensure that the description is rendering as it should..." | ||
descriptiontest='<meta name="description" content="This post tests if we are properly filtering XML reserved characters in page metadata & < > ' "">' | ||
if [[ $(grep "$descriptiontest" $testpage) ]] | ||
then | ||
echo "SUCCESS!" | ||
else | ||
echo "FAILED. The page description line we were looking for did not render properly." | ||
echo "" | ||
echo "Pattern we were trying to match:" | ||
echo "$descriptiontest" | ||
echo "===========" | ||
echo "Full line that contains a discrepancy:" | ||
echo "$(grep '<meta name="description"' $testpage | head -1)" | ||
exit 1 | ||
fi |
Oops, something went wrong.