| Dave Borowitz | 1218194 | 2018-02-12 09:22:45 -0500 | [diff] [blame] | 1 | // Copyright 2018 Google Inc. All Rights Reserved. |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | package com.google.gitiles.doc; |
| 16 | |
| 17 | /** |
| 18 | * Constant definitions for Soy utilities. |
| 19 | * |
| 20 | * <p>These constant definitions are copied from Soy internal packages, and are repeated here at the |
| 21 | * request of Soy team to limit our dependencies on their internal packages. The text still refers |
| 22 | * to "zSoyz" for consistency with other non-Markdown parts of Gitiles. |
| 23 | */ |
| 24 | final class SoyConstants { |
| 25 | /** |
| 26 | * Innocuous output when an image data URI fails escaping. |
| 27 | * |
| 28 | * <p>When escaper fails, we need to return something that is both clearly an image, but clearly |
| 29 | * invalid. We don't want the browser to fetch anything. We also don't necessarily want a |
| 30 | * transparent gif, since it doesn't alert developers to an issue. And finally, by not starting |
| 31 | * with GIF89a, we ensure the browser doesn't attempt to actually decode it and crash. |
| 32 | * |
| 33 | * <p>Based on {@link |
| David Pursehouse | 1c84319 | 2018-05-25 11:07:55 +0900 | [diff] [blame] | 34 | * com.google.template.soy.shared.internal.EscapingConventions.FilterImageDataUri}. |
| Dave Borowitz | 1218194 | 2018-02-12 09:22:45 -0500 | [diff] [blame] | 35 | */ |
| 36 | static String IMAGE_URI_INNOCUOUS_OUTPUT = "data:image/gif;base64,zSoyz"; |
| 37 | |
| 38 | /** |
| 39 | * Innocuous output when a URI fails escaping. |
| 40 | * |
| 41 | * <p>about:invalid is registered in http://www.w3.org/TR/css3-values/#about-invalid: "The |
| 42 | * about:invalid URI references a non-existent document with a generic error condition. It can be |
| 43 | * used when a URI is necessary, but the default value shouldn't be resolveable as any type of |
| 44 | * document." |
| 45 | * |
| 46 | * <p>Based on {@link |
| David Pursehouse | 1c84319 | 2018-05-25 11:07:55 +0900 | [diff] [blame] | 47 | * com.google.template.soy.shared.internal.EscapingConventions.FilterNormalizeUri}. |
| Dave Borowitz | 1218194 | 2018-02-12 09:22:45 -0500 | [diff] [blame] | 48 | */ |
| 49 | static String NORMAL_URI_INNOCUOUS_OUTPUT = "about:invalid#zSoyz"; |
| 50 | } |