<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Bad escaped character in JSON: esriConfig in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/bad-escaped-character-in-json-esriconfig/m-p/1356034#M82993</link>
    <description>&lt;P&gt;The backslash in a JavaScript string is an escape character that is combined with the character immediately following it to represent a special character, for example \n is a newline character, and \t is a tab character.&amp;nbsp; The parser sees the backslashes in your value, but \c isn't a valid character.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To get around this, you need to escape your backslashes so that the compiler interprets them properly.&amp;nbsp; For instance "assets\config\config.json" should instead be "assets\\config\\config.json".&amp;nbsp; You can do this with something like:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var urlParams = new URLSearchParams(window.location.search);
var configPath = urlParams.get("config").replace(/\\/g, "\\\\");&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 01 Dec 2023 23:17:28 GMT</pubDate>
    <dc:creator>JoelBennett</dc:creator>
    <dc:date>2023-12-01T23:17:28Z</dc:date>
    <item>
      <title>Bad escaped character in JSON: esriConfig</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/bad-escaped-character-in-json-esriconfig/m-p/1355732#M82986</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;I am receiving multiple worker exceptions when the mapview loads. It does not affect anything as I believe the issue is in logger.&lt;/P&gt;&lt;P&gt;My site supports locale and config as querystring parameters. Adding the config parameter seems to trigger the issue. Example:&amp;nbsp;&lt;A href="http://localhost:5173/?locale=fr&amp;amp;config=assets\config\config.json" target="_blank"&gt;http://localhost:5173/?locale=fr&amp;amp;config=assets\config\config.json&lt;/A&gt;&amp;nbsp;causes the issue but&amp;nbsp;&lt;A href="http://localhost:5173/?locale=fr" target="_blank"&gt;http://localhost:5173/?locale=fr&lt;/A&gt;&amp;nbsp;does not. I have also tried&amp;nbsp;&lt;A href="http://localhost:5173/?locale=fr&amp;amp;config=assets\config\config.json" target="_blank"&gt;http://localhost:5173/?locale=fr&amp;amp;config=assets%5cconfig%5cconfig.json&lt;/A&gt;&amp;nbsp;but that made no difference. My config file still loads up fine in the javascript either way.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ren_Tnire_0-1701446021386.png" style="width: 772px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/87739i6E3A6E5129C0DC03/image-dimensions/772x83?v=v2" width="772" height="83" role="button" title="Ren_Tnire_0-1701446021386.png" alt="Ren_Tnire_0-1701446021386.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;let globalId=0;const outgoing=new Map,configuration=JSON.parse('{"esriConfig":{"applicationName":"","applicationUrl":"http://localhost:5173/?locale=fr&amp;amp;config=assets\\config\\config.json","assetsPath":"https://js.arcgis.com/4.28/@arcgis/core/assets","fontsUrl":"https://static.arcgis.com/fonts","geometryServiceUrl":"https://utility.arcgisonline.com/arcgis/rest/services/Geometry/GeometryServer","geoRSSServiceUrl":"https://utility.arcgis.com/sharing/rss","kmlServiceUrl":"https://utility.arcgis.com/sharing/kml","userPrivilegesApplied":true,"portalUrl":"https://nsdnr-forestry.maps.arcgis.com","routeServiceUrl":"https://route-api.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World","workers":{"loaderConfig":{"has":{},"paths":{},"map":{},"packages":[]},"workerPath":"https://js.arcgis.com/4.28/@arcgis/core/assets/esri/core/workers/RemoteClient.js","useDynamicImport":false},"request":{"crossOriginNoCorsDomains":null,"httpsDomains":["arcgis.com","arcgisonline.com","esrikr.com","premiumservices.blackbridge.com","esripremium.accuweather.com","gbm.digitalglobe.com","firstlook.digitalglobe.com","msi.digitalglobe.com"],"interceptors":[],"maxUrlLength":2000,"priority":"high","proxyRules":[],"proxyUrl":null,"timeout":60000,"trustedServers":[],"useIdentity":true},"log":{"interceptors":[],"level":null},"defaultAssetsPath":"https://js.arcgis.com/4.28/@arcgis/core/assets","locale":"fr","has":{"esri-csp-restrictions":false,"esri-2d-debug":false,"featurelayer-pbf":true,"featurelayer-simplify-thresholds":[0.5,0.5,0.5,0.5],"featurelayer-simplify-payload-size-factors":[1,1,4],"esri-atomics":true,"esri-shared-array-buffer":false,"esri-workers-arraybuffer-transfer":true,"feature-polyline-generalization-factor":1,"host-webworker":1}},"loaderConfig":{"async":true,"isDebug":false,"locale":"fr","has":{"csp-restrictions":1,"dojo-test-sniff":0,"host-webworker":1},"map":{},"packages":[],"paths":{}},"kernelInfo":{"buildDate":"20231115","fullVersion":"4.28.10","revision":"a6fcf2901ef678ef17a528e11b93ffe09e3ec267"}}');self.esriConfig=configuration.esriConfig;const workerPath=self.esriConfig.workers.workerPath,HANDSHAKE=0,OPEN=1,OPENED=2,RESPONSE=3,INVOKE=4,ABORT=5;function createAbortError(){const e=new Error("Aborted");return e.name="AbortError",e}function receiveMessage(e){return e&amp;amp;&amp;amp;e.data?"string"==typeof e.data?JSON.parse(e.data):e.data:null}function invokeStaticMessage(e,o,r){const t=r&amp;amp;&amp;amp;r.signal,n=globalId++;return new Promise(((r,s)=&amp;gt;{if(t){if(t.aborted)return s(createAbortError());t.addEventListener("abort",(()=&amp;gt;{outgoing.get(n)&amp;amp;&amp;amp;(outgoing.delete(n),self.postMessage({type:ABORT,jobId:n}),s(createAbortError()))}))}outgoing.set(n,{resolve:r,reject:s}),self.postMessage({type:INVOKE,jobId:n,methodName:e,abortable:null!=t,data:o})}))}let workerRevisionChecked=!1;function checkWorkerRevision(e){if(!workerRevisionChecked&amp;amp;&amp;amp;e.kernelInfo){workerRevisionChecked=!0;const{revision:o,fullVersion:r}=configuration.kernelInfo,{revision:t,fullVersion:n,version:s}=e.kernelInfo;esriConfig.assetsPath!==esriConfig.defaultAssetsPath&amp;amp;&amp;amp;o!==t&amp;amp;&amp;amp;console.warn(`Version mismatch detected between ArcGIS Maps SDK for JavaScript modules and assets. For more information visit https://bit.ly/3QnsuSo.\nModules version: ${r}\nAssets version: ${n??s}\nAssets path: ${esriConfig.assetsPath}`)}}function messageHandler(e){const o=receiveMessage(e);if(!o)return;const r=o.jobId;switch(o.type){case OPEN:let n;function t(e){const o=n.connect(e);self.postMessage({type:OPENED,jobId:r,data:o},[o])}"function"==typeof define&amp;amp;&amp;amp;define.amd?require([workerPath],(e=&amp;gt;{n=e.default||e,checkWorkerRevision(n),n.loadWorker(o.modulePath).then((e=&amp;gt;e||new Promise((e=&amp;gt;{require([o.modulePath],e)})))).then(t)})):"System"in self&amp;amp;&amp;amp;"function"==typeof System.import?System.import(workerPath).then((e=&amp;gt;(n=e.default,checkWorkerRevision(n),n.loadWorker(o.modulePath)))).then((e=&amp;gt;e||System.import(o.modulePath))).then(t):esriConfig.workers.useDynamicImport?import(workerPath).then((e=&amp;gt;{n=e.default||e,checkWorkerRevision(n),n.loadWorker(o.modulePath).then((e=&amp;gt;e||import(o.modulePath))).then(t)})):(self.RemoteClient||importScripts(workerPath),n=self.RemoteClient.default||self.RemoteClient,checkWorkerRevision(n),n.loadWorker(o.modulePath).then(t));break;case RESPONSE:if(outgoing.has(r)){const s=outgoing.get(r);outgoing.delete(r),o.error?s.reject(JSON.parse(o.error)):s.resolve(o.data)}}}self.dojoConfig=configuration.loaderConfig,esriConfig.workers.loaderUrl&amp;amp;&amp;amp;(self.importScripts(esriConfig.workers.loaderUrl),"function"==typeof require&amp;amp;&amp;amp;"function"==typeof require.config&amp;amp;&amp;amp;require.config(configuration.loaderConfig)),self.addEventListener("message",messageHandler),self.postMessage({type:0});&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Dec 2023 15:59:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/bad-escaped-character-in-json-esriconfig/m-p/1355732#M82986</guid>
      <dc:creator>René_Ténière</dc:creator>
      <dc:date>2023-12-01T15:59:13Z</dc:date>
    </item>
    <item>
      <title>Re: Bad escaped character in JSON: esriConfig</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/bad-escaped-character-in-json-esriconfig/m-p/1356034#M82993</link>
      <description>&lt;P&gt;The backslash in a JavaScript string is an escape character that is combined with the character immediately following it to represent a special character, for example \n is a newline character, and \t is a tab character.&amp;nbsp; The parser sees the backslashes in your value, but \c isn't a valid character.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To get around this, you need to escape your backslashes so that the compiler interprets them properly.&amp;nbsp; For instance "assets\config\config.json" should instead be "assets\\config\\config.json".&amp;nbsp; You can do this with something like:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var urlParams = new URLSearchParams(window.location.search);
var configPath = urlParams.get("config").replace(/\\/g, "\\\\");&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Dec 2023 23:17:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/bad-escaped-character-in-json-esriconfig/m-p/1356034#M82993</guid>
      <dc:creator>JoelBennett</dc:creator>
      <dc:date>2023-12-01T23:17:28Z</dc:date>
    </item>
    <item>
      <title>Re: Bad escaped character in JSON: esriConfig</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/bad-escaped-character-in-json-esriconfig/m-p/1356756#M83012</link>
      <description>&lt;P&gt;The url parameter is decoded properly within code (decodeURI() will properly return the escaped parameter). The issue is that you cannot rely on user validation. Upon further digging I have found that the applicationUrl is not uri encoded when added to the esriConfig:&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;JSON.parse('{"esriConfig":{"applicationName":"","applicationUrl":"http://localhost:5173/?locale=fr&amp;amp;config=assets\\config\\config.json",&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;JSON.parse() does not seem to accept an escaped \ (\\).&lt;/P&gt;&lt;P&gt;If the input URL is:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;http://localhost:5173/?locale=fr&amp;amp;config=assets%5cconfig%5cconfig.json&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;then there is no problem.&lt;/P&gt;&lt;P&gt;It would be proper if esri fixed the code that adds applicationUrl so that it is properly encoded, i.e. &lt;SPAN&gt;encodeURI(&lt;/SPAN&gt;&lt;SPAN&gt;window&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;location&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;href&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;. You cannot rely on the fact that the client will validate the url parameter. If you look at past WAB functionality, it accepted non-encoded or escaped backslashes as config parameters.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Dec 2023 13:37:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/bad-escaped-character-in-json-esriconfig/m-p/1356756#M83012</guid>
      <dc:creator>René_Ténière</dc:creator>
      <dc:date>2023-12-05T13:37:13Z</dc:date>
    </item>
  </channel>
</rss>

