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

fix(apostrophe): fixes issue with apostrophe breaking config #2681

Merged

Conversation

DamonU2
Copy link
Member

@DamonU2 DamonU2 commented Jan 10, 2025

Description

Fixes issue breaking configs by using JSON.stringify on config already stringified
Closes #2629

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

https://damonu2.github.io/geoview/demos-navigator.html?config=./configs/navigator/06-basic-footer.json
https://damonu2.github.io/geoview/demo-osdp-integration.html

Checklist:

  • I have build (rush build) and deploy (rush host) my PR
  • I have connected the issues(s) to this PR
  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • I have created new issue(s) related to the outcome of this PR is needed
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

This change is Reviewable

@DamonU2 DamonU2 requested a review from jolevesq January 10, 2025 18:13
@DamonU2 DamonU2 self-assigned this Jan 10, 2025
@@ -189,7 +189,7 @@
// Create a data-config attribute and set config value on the div
const att = document.createAttribute(url ? 'data-config-url' : 'data-config');
// Clean apostrophes in the config
att.value = JSON.stringify(mapConfig).replace(/'/g, "\\'");
att.value = mapConfig.replace(/'/g, "\\'");

Check failure

Code scanning / CodeQL

Incomplete string escaping or encoding High

This does not escape backslash characters in the input.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Member Author

@DamonU2 DamonU2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 2 files reviewed, 1 unresolved discussion (waiting on @Github-advanced-security[bot] and @jolevesq)

@@ -189,7 +189,7 @@
// Create a data-config attribute and set config value on the div
const att = document.createAttribute(url ? 'data-config-url' : 'data-config');
// Clean apostrophes in the config
att.value = JSON.stringify(mapConfig).replace(/'/g, "\\'");
att.value = mapConfig.replace(/'/g, "\\'");
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@jolevesq jolevesq merged commit 7606951 into Canadian-Geospatial-Platform:develop Jan 10, 2025
5 of 6 checks passed
@DamonU2 DamonU2 deleted the apostrophe-fix branch January 10, 2025 19:21
@DamonU2 DamonU2 restored the apostrophe-fix branch January 10, 2025 20:52
@DamonU2 DamonU2 deleted the apostrophe-fix branch January 13, 2025 15:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] Issue with Apostrophes in Config File
2 participants