-
Notifications
You must be signed in to change notification settings - Fork 685
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
Incorrect special character handling in Haddock response files #3004
Comments
Reproduced. |
If I understand correctly, we can't fix this until haskell/haddock#379 is fixed, because Haddock does not yet support the standard GCC response file format. |
/cc @randen |
If you like, we can disable response files for now until Haddock fixes this. |
Yes, needs to be fixed in Haddock first. |
Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
The relevant code to fix is Distribution.Simple.Haddock, in renderArgs. Here's a hokey patch that doesn't work:
|
Arrrgv! Right, so even with cabal doing the escaping, e.g., snoyberg's ghc patch for response-file-generation, the called program must also be aware of the escaping and do the unescaping. Haddock > 2.16.1 was only used in building the docs for the recent HP releases on exactly one machine, so that is why this problem has laid dormant until we are now post-7.10.3. Is escaping backslashes, newlines, and double-quote sufficient? When supported, we encode into UTF-8 in the above quoted code, but is anyone aware of any other caveats that are not obvious to me? Short of reading the gcc code (e.g., the 2005 gcc patch referenced by https://gcc.gnu.org/wiki/Response_Files), is anyone aware of an actual "spec" for the " gcc -compatible syntax" of a response file? edit: If we disable response file generation in cabal, as a work-around, it has not been depended upon by anyone, yet (except the HP build). |
This part of |
This may sound gross, but what if we do something like base64-encode each argument chunk, separating each by newlines? No escaping necessary (other than whatever the receiving program expects for its own argument parameters, such as whether it allows newlines, etc.). Not "standard" (like there is a standard for this) but should be completely reliable and robust. Since it is only for cabal-haddock interaction, it is rather limited. Would humans build such a response file? Since getting all the escaping right manually would likely involve a tool of some kind to be reliable and repeatable (no one is going to hand-create a response file and get it right the first time), it is not so onerous to have the user use a base64-encoding of each argument chunk. Also, the manual use case is probably not really the requirement here, is it? Anyway, I'm working on this problem, the gcc-spec-way, but please consider this other alternative for fun. |
I'd much prefer to solve this the standard way. People may want to inspect Cabal-generated response files; other tools/scripts may want to generate them. |
Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
For anyone following this ticket: the issue is fixed in Cabal >= 1.22.7.0 and Haddock >= 2.16.2. Specifically, the version of Haddock that comes with GHC 8 RC2 (2.17.0) includes the fix. |
@23Skidoo do you mean
? |
Thanks, fixed. |
To complete the story for archeologists (including myself--I wasn't able to find it immediately), I should have linked the PR that was used for the Haddock part of this: haskell/haddock/pull/470 |
This has been causing us quite some trouble with our Stackage builds (see: commercialhaskell/stackage#1018). I recommend considering this a major issue worthy of an emergency patch, since the following combination seems to always cause failed Haddock builds:
When generating a response file for the Haddock arguments, the current code in Cabal simply calls
hPutStrLn
on the argument without any escaping. When an argument has a newline (like the synopsis), anything after the newline is treated as its own argument.Solution: use response file escaping to pass in all arguments. As an example, that's how I implemented response file support in GHC, see: ghc/ghc@296bc70#diff-782eb6a039b579ec019e5a4009f45058R1281
The text was updated successfully, but these errors were encountered: