RFR: JDK-8291509 Minor cleanup could be done in sun.security [v6]

Sean Mullan mullan at openjdk.org
Tue Sep 6 20:38:59 UTC 2022


On Tue, 6 Sep 2022 17:53:32 GMT, Weijun Wang <weijun at openjdk.org> wrote:

>> src/java.base/share/classes/sun/security/provider/PolicyParser.java line 1180:
>> 
>>> 1178:                 // and then in a java string, it's escaped again
>>> 1179: 
>>> 1180:                 out.print(name.replaceAll("\\\\", "\\\\\\\\").replaceAll("\"", "\\\\\\\""));
>> 
>> Why does IJ say this is the same? This appears to replace backslash-quote with quote.
>
> My understanding: In regex, there is no need to escape `"`, so `"` is the same as `"`.

Ok,but the regex is `"\\""`, so shouldn't it keep the double-backslash at the beginning (`\`)?, i.e.:

`...replaceAll("\"", "\\\\\\""));`

-------------

PR: https://git.openjdk.org/jdk/pull/9972


More information about the security-dev mailing list