yesodweb/shakespeare

shakespeare escape bug in #\"

ncaq opened this issue · 2 comments

ncaq commented

There is a bug in the escaping of shakespeare.

I think to should be to use jsFile,
However, jsFile = juliusFile.

I write to Shakespeare/test/Text/Shakespeare/TextSpec.hs

    it "Non-expression sharps do not hinder backslash" $ do
      telper "#\\\"" [text|#\"|]

It has been reproduced.
It is a deep problem because.

This is a real string.

https://github.com/facebook/react/blob/50addf4c0e411e351de7290c8c60ec775c25c8c4/packages/react-reconciler/src/ReactDebugFiberPerf.js#L103

is bundled in webpack development.

in eval

#$\" + debugID + \"

My quick-fix

rawJsFile :: FilePath -> Q Exp
rawJsFile fp = do
  fileString <- readFileRecompileQ fp
  [|rawStringToJavascript fileString|]

rawStringToJavascript :: String -> Javascript
rawStringToJavascript = toJavascript . rawJS

The reload version of the function can only be written inside shakespeare, so there is nothing I can do about it.

I tried to find a way to fix this bug, but I couldn't find it.

Proposal

I suggest adding rawJsFile which adds JS without embedding anything.

Some users mistakenly think that the contents of both jsFile and juliusFile are different.
It is suggested that the jsFile system be deprecated.

Even after the bug is fixed, there are some people who don't want to embed variables but want to embed JavaScript files.

There's a lot of stuff here which seems contradictory. Is this actually a bug, or "this isn't behaving the way I expected it to?"

I'm OK with the proposal overall to reduce confusing names via deprecation, and to add a new piece of functionality. I just want clarity on whether there's an actual bug here versus confusing language.

ncaq commented

This is bug.
The string literal quote " in string literal must be escape.
webpack escape it.
However julius remove backslash when prefix sharp.
So I import react, and it occur syntax parse error.