[Fixes #13968] Fix of the JS SyntaxError in the Import Resources UI#13969
[Fixes #13968] Fix of the JS SyntaxError in the Import Resources UI#13969
Conversation
Summary of ChangesHello @Gpetrak, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses a JavaScript syntax error that occurred in the Import Resources UI. The fix involves properly escaping string values for resource titles and abstracts when they are embedded into JavaScript code within the template, thereby preventing malformed script and ensuring the UI functions as expected. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request correctly addresses a JavaScript syntax error by using the escapejs filter for dynamic content injected into a JavaScript block. The fix is appropriate and necessary. I've provided one suggestion to refine the filter chain for the abstract field to ensure truncation is applied to the plain text content after HTML tags are removed, which will produce more predictable and correct output.
| title: '{{ resource_meta.title }}', | ||
| abstract: '{{ resource_meta.abstract|safe|truncatechars:20|striptags }}', | ||
| title: '{{ resource_meta.title|escapejs }}', | ||
| abstract: '{{ resource_meta.abstract|truncatechars:20|striptags|escapejs }}', |
There was a problem hiding this comment.
The order of the truncatechars and striptags filters should be swapped. It is more robust to strip HTML tags before truncating the string. This ensures that truncation applies to the actual content text rather than the HTML markup, preventing broken HTML and providing a more accurate truncation of the visible text.
abstract: '{{ resource_meta.abstract|striptags|truncatechars:20|escapejs }}',
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #13969 +/- ##
==========================================
- Coverage 74.24% 74.22% -0.03%
==========================================
Files 947 948 +1
Lines 56620 56591 -29
Branches 7675 7668 -7
==========================================
- Hits 42038 42005 -33
- Misses 12892 12898 +6
+ Partials 1690 1688 -2 🚀 New features to boost your workflow:
|
This PR was created according to this issue: #13968
Checklist
For all pull requests:
The following are required only for core and extension modules (they are welcomed, but not required, for contrib modules):
Submitting the PR does not require you to check all items, but by the time it gets merged, they should be either satisfied or inapplicable.