Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Whoever wrote these `String.replaceAll` calls was a bit confused about how backslashes behave in the replacement text. They actually behave less like backslashes in generic `String` literals, and more like backslashes in regular expressions. For example, to replace a newline with a backslash followed by an `n`, the replacement text should be `\\\\n`, not `\\n`. I've added a test for `com.ibm.wala.types.generics.MethodTypeSignature.getArguments()` to affirm that my changes there leave us with an implementation that has the intended effects. I haven't added a `com.ibm.wala.cast.js.html.DomLessSourceExtractor.HtmlCallback.quotify(String)` test, though, because this method is buried too deep inside `protected` APIs that are difficult for a unit test to get access to. Instead, to argue that the new code matches the original `quotify` authors' likely intent, contrast these two JShell approximations: * old code: ```plain jshell> System.out.println("foo\n\"bar".replaceAll("\"", "\\\"").replaceAll("\n", "\\n")) foon"bar ``` * new code: ```plain System.out.println("foo\n\"bar".replaceAll("\"", "\\\\\"").replaceAll("\n", "\\\\n")) foo\n\"bar ```
- Loading branch information