Skip to content
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

Update documentation #250

Closed
wants to merge 1 commit into from
Closed

Update documentation #250

wants to merge 1 commit into from

Conversation

cjlapao
Copy link
Collaborator

@cjlapao cjlapao commented Dec 10, 2024

No description provided.

@boring-cyborg boring-cyborg bot added the documentation Improvements or additions to documentation label Dec 10, 2024
@cjlapao cjlapao added this to the 0.9.12 milestone Dec 10, 2024
$el.each(function(i) {
var title = $(this).attr('title');
if (title) {
$insert.append("<li class=\"tab\"><a href=\"#\">" + title + "</a></li>");

Check warning

Code scanning / CodeQL

DOM text reinterpreted as HTML Medium documentation

DOM text
is reinterpreted as HTML without escaping meta-characters.

Copilot Autofix AI 22 days ago

To fix the problem, we need to ensure that the title attribute is properly escaped before being inserted into the HTML string. This can be done using a utility function that escapes special HTML characters. We will create a function to escape the title attribute and use it in the listLanguages function.

Suggested changeset 1
docs/docs/github-actions/assets/js/app.js

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/docs/docs/github-actions/assets/js/app.js b/docs/docs/github-actions/assets/js/app.js
--- a/docs/docs/github-actions/assets/js/app.js
+++ b/docs/docs/github-actions/assets/js/app.js
@@ -110,2 +110,13 @@
 
+	function escapeHtml(text) {
+	    var map = {
+	        '&': '&amp;',
+	        '<': '&lt;',
+	        '>': '&gt;',
+	        '"': '&quot;',
+	        "'": '&#039;'
+	    };
+	    return text.replace(/[&<>"']/g, function(m) { return map[m]; });
+	}
+
 	function listLanguages($el, $insert) {
@@ -114,3 +125,3 @@
 			if (title) {
-				$insert.append("<li class=\"tab\"><a href=\"#\">" + title + "</a></li>");
+				$insert.append("<li class=\"tab\"><a href=\"#\">" + escapeHtml(title) + "</a></li>");
 			}
EOF
@@ -110,2 +110,13 @@

function escapeHtml(text) {
var map = {
'&': '&amp;',
'<': '&lt;',
'>': '&gt;',
'"': '&quot;',
"'": '&#039;'
};
return text.replace(/[&<>"']/g, function(m) { return map[m]; });
}

function listLanguages($el, $insert) {
@@ -114,3 +125,3 @@
if (title) {
$insert.append("<li class=\"tab\"><a href=\"#\">" + title + "</a></li>");
$insert.append("<li class=\"tab\"><a href=\"#\">" + escapeHtml(title) + "</a></li>");
}
Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
$el.each(function(i) {
var title = $(this).attr('title');
if (title) {
$insert.append("<li class=\"tab\"><a href=\"#\">" + title + "</a></li>");

Check warning

Code scanning / CodeQL

DOM text reinterpreted as HTML Medium documentation

DOM text
is reinterpreted as HTML without escaping meta-characters.

Copilot Autofix AI 22 days ago

To fix the problem, we need to ensure that the title attribute is properly escaped before being inserted into the HTML. This can be achieved by using a function that escapes special HTML characters, preventing any potential XSS attacks.

The best way to fix this without changing existing functionality is to create a utility function that escapes HTML characters and use it to sanitize the title attribute before concatenating it into the HTML string.

Suggested changeset 1
docs/docs/github-actions/docs/github-actions/assets/js/app.js

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/docs/docs/github-actions/docs/github-actions/assets/js/app.js b/docs/docs/github-actions/docs/github-actions/assets/js/app.js
--- a/docs/docs/github-actions/docs/github-actions/assets/js/app.js
+++ b/docs/docs/github-actions/docs/github-actions/assets/js/app.js
@@ -110,2 +110,17 @@
 
+	function escapeHtml(text) {
+		return text.replace(/[&<>"'`=\/]/g, function (s) {
+			return ({
+				'&': '&amp;',
+				'<': '&lt;',
+				'>': '&gt;',
+				'"': '&quot;',
+				"'": '&#39;',
+				'/': '&#x2F;',
+				'`': '&#x60;',
+				'=': '&#x3D;'
+			})[s];
+		});
+	}
+
 	function listLanguages($el, $insert) {
@@ -114,3 +129,3 @@
 			if (title) {
-				$insert.append("<li class=\"tab\"><a href=\"#\">" + title + "</a></li>");
+				$insert.append("<li class=\"tab\"><a href=\"#\">" + escapeHtml(title) + "</a></li>");
 			}
EOF
@@ -110,2 +110,17 @@

function escapeHtml(text) {
return text.replace(/[&<>"'`=\/]/g, function (s) {
return ({
'&': '&amp;',
'<': '&lt;',
'>': '&gt;',
'"': '&quot;',
"'": '&#39;',
'/': '&#x2F;',
'`': '&#x60;',
'=': '&#x3D;'
})[s];
});
}

function listLanguages($el, $insert) {
@@ -114,3 +129,3 @@
if (title) {
$insert.append("<li class=\"tab\"><a href=\"#\">" + title + "</a></li>");
$insert.append("<li class=\"tab\"><a href=\"#\">" + escapeHtml(title) + "</a></li>");
}
Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
@cjlapao cjlapao closed this Dec 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant