neherlab / covid19_scenarios

Models of COVID-19 outbreak trajectories and hospital demand
https://covid19-scenarios.org
MIT License
1.36k stars 354 forks source link

JSURL "'" character converted to "%27" in Chrome address bar #445

Open dkozar opened 4 years ago

dkozar commented 4 years ago

🐛 Bug Report

We noticed that, for some reason, JSURL "'" converted to "%27" in the address bar of Chrome (Windows, not sure about Mac). The Firefox displays "'".

However, copy-pasting the URL from both browsers and pasting into email produces the same result, the one with "%27":

https://covid19-scenarios-3dkfdt4h0.now.sh/?~(current~%27CHE-Basel-Stadt~containment~(~(id~%2706ad1640-ce01-41c0-8dc2-78fbbfbd8dd6~name~%27Intervention*20*231~color~%27*23bf5b17~mitigationValue~0.2~timeRange~(tMin~1583971200000~tMax~1598918400000))~(id~%27a353e47f-ed52-4517-9cb5-063878edbbca~name~%27Intervention*20*232~color~%27*23666666~mitigationValue~0.6~timeRange~(tMin~1585440000000~tMax~1598918400000)))~population~(cases~%27CHE-Basel-Stadt~country~%27Switzerland~hospitalBeds~698~ICUBeds~80~importsPerDay~0.1~populationServed~195000~suspectedCasesToday~39)~epidemiological~(infectiousPeriod~3~latencyTime~3~lengthHospitalStay~4~lengthICUStay~14~overflowSeverity~2~peakMonth~0~r0~2~seasonalForcing~0)~simulation~(simulationTimeRange~(tMin~1581724800000~tMax~1598918400000)~numberStochasticRuns~0)~ageDistribution~(0-9~884945~10-19~834866~20-29~1039727~30-39~1219227~40-49~1166590~50-59~1320623~60-69~977436~70-79~751994~80*2b~459214))

We're not sure if this is something we should care about, as long as such URL is preperly deserialized.

Note: "'" character is part of JSURL specs.

How to reproduce

Steps to reproduce the issue:

  1. Open the application in a browser
  2. Clik the RUN button
  3. Examine the link in the address bar

Chrome:

chrome

Firefox:

firefox

Related:

Note that the apostrophe is converted by the browser, unit tests prove that: https://github.com/neherlab/covid19_scenarios/blob/master/src/components/Main/state/serialization/URLSerializer.test.ts#L61

ivan-aksamentov commented 4 years ago

@dkozar Oh, it's an apostrophe, not a single quote https://www.fileformat.info/info/unicode/char/0027/index.htm

This is weird.

@nnoll @rneher Do we have any weird symbols coming from data again, like remember this odd space character in https://github.com/neherlab/covid19_scenarios/issues/273 ?

If so, maybe we should have a sort of a whitelist of characters and should run a check on data generation. Extended Latin set should do for now, I think. ASCII check will probably be too narrow, but may help to find oddities as a tool for the dev process.

rneher commented 4 years ago

Would this only be an issue for generated data, or could this be a problem for the names of mitigation measures as well?

dkozar commented 4 years ago

@rneher it seems to be a cosmetic issue only (and the link is a bit longer).

The link normally deserializes to the original object, both in tests and browser:

image

We could replace JSURL with other de/serilization whenever needed. Only two lines of code must be changed for that (and tests updated):

guandiyiyi commented 4 years ago

@dkozar I found this issue is fixed in version 0.1.3 as mentioned in https://github.com/Sage/jsurl/issues/6, did you try?

dkozar commented 4 years ago

We’re using JSURL version 0.1.5:

https://github.com/neherlab/covid19_scenarios/blob/master/package.json