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

chore(docs): auto-generate api reference (VIV-2180) #1984

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

RichardHelm
Copy link
Contributor

No description provided.

fs.readFileSync(`dist/libs/wrapper-gen/component-metadata.json`, 'utf-8')
);

const escapeMarkdown = (text = '') => text.replace(/([<>{}])/gm, '\\$1');

Check failure

Code scanning / CodeQL

Incomplete string escaping or encoding High documentation

This does not escape backslash characters in the input.

Copilot Autofix AI 3 months ago

To fix the problem, we need to ensure that backslashes are also escaped in the escapeMarkdown function. This can be done by adding backslashes to the list of characters to be escaped. We will use a regular expression that includes backslashes and ensure that all occurrences are replaced.

  • Modify the escapeMarkdown function to include backslashes in the characters to be escaped.
  • Update the regular expression to handle backslashes properly.
Suggested changeset 1
apps/docs/shortcodes/apiReference.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/apps/docs/shortcodes/apiReference.js b/apps/docs/shortcodes/apiReference.js
--- a/apps/docs/shortcodes/apiReference.js
+++ b/apps/docs/shortcodes/apiReference.js
@@ -8,3 +8,3 @@
 
-const escapeMarkdown = (text = '') => text.replace(/([<>{}])/gm, '\\$1');
+const escapeMarkdown = (text = '') => text.replace(/([\\<>{}])/gm, '\\$1');
 
EOF
@@ -8,3 +8,3 @@

const escapeMarkdown = (text = '') => text.replace(/([<>{}])/gm, '\\$1');
const escapeMarkdown = (text = '') => text.replace(/([\\<>{}])/gm, '\\$1');

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

const escapeMarkdown = (text = '') => text.replace(/([<>{}])/gm, '\\$1');

const escapeType = (text = '') => text.replace(/([|])/gm, '\\$1');

Check failure

Code scanning / CodeQL

Incomplete string escaping or encoding High documentation

This does not escape backslash characters in the input.

Copilot Autofix AI 3 months ago

To fix the problem, we need to ensure that the escapeType function also escapes backslashes. This can be done by adding an additional replacement step to handle backslashes before escaping the pipe character. The best way to fix this without changing existing functionality is to use a regular expression to replace backslashes with double backslashes and then proceed with the existing replacement for the pipe character.

Suggested changeset 1
apps/docs/shortcodes/apiReference.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/apps/docs/shortcodes/apiReference.js b/apps/docs/shortcodes/apiReference.js
--- a/apps/docs/shortcodes/apiReference.js
+++ b/apps/docs/shortcodes/apiReference.js
@@ -10,3 +10,3 @@
 
-const escapeType = (text = '') => text.replace(/([|])/gm, '\\$1');
+const escapeType = (text = '') => text.replace(/\\/g, '\\\\').replace(/([|])/gm, '\\$1');
 
EOF
@@ -10,3 +10,3 @@

const escapeType = (text = '') => text.replace(/([|])/gm, '\\$1');
const escapeType = (text = '') => text.replace(/\\/g, '\\\\').replace(/([|])/gm, '\\$1');

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
Comment on lines +35 to +38
(resolvedType.length === 1
? `\`${resolvedType[0].text}\``
: `*Enum*:<br/>${generateEnumType(resolvedType)}`
).replace(/\|/g, '\\|'),

Check failure

Code scanning / CodeQL

Incomplete string escaping or encoding High documentation

This does not escape backslash characters in the input.

Copilot Autofix AI 3 months ago

To fix the problem, we need to ensure that backslashes are properly escaped in the input strings. This can be achieved by adding a replacement for backslashes before any other replacements. Additionally, we should ensure that all replacements use the global flag to replace all occurrences of the target characters.

The best way to fix the problem without changing existing functionality is to update the escapeMarkdown, escapeType, and escapeDescription functions to handle backslashes and use the global flag for all replacements. This involves modifying the regular expressions used in these functions.

Suggested changeset 1
apps/docs/shortcodes/apiReference.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/apps/docs/shortcodes/apiReference.js b/apps/docs/shortcodes/apiReference.js
--- a/apps/docs/shortcodes/apiReference.js
+++ b/apps/docs/shortcodes/apiReference.js
@@ -8,5 +8,5 @@
 
-const escapeMarkdown = (text = '') => text.replace(/([<>{}])/gm, '\\$1');
+const escapeMarkdown = (text = '') => text.replace(/\\/g, '\\\\').replace(/([<>{}])/g, '\\$1');
 
-const escapeType = (text = '') => text.replace(/([|])/gm, '\\$1');
+const escapeType = (text = '') => text.replace(/\\/g, '\\\\').replace(/([|])/g, '\\$1');
 
EOF
@@ -8,5 +8,5 @@

const escapeMarkdown = (text = '') => text.replace(/([<>{}])/gm, '\\$1');
const escapeMarkdown = (text = '') => text.replace(/\\/g, '\\\\').replace(/([<>{}])/g, '\\$1');

const escapeType = (text = '') => text.replace(/([|])/gm, '\\$1');
const escapeType = (text = '') => text.replace(/\\/g, '\\\\').replace(/([|])/g, '\\$1');

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant