diff --git a/build.gradle b/build.gradle index 46bcdda92..5d5f2e4b1 100644 --- a/build.gradle +++ b/build.gradle @@ -318,7 +318,7 @@ subprojects { // expose to users. if (project.name != 'docs') { javadocSource << project.sourceSets.main.allJava - javadocClasspath << project.sourceSets.main.compileClasspath + javadocClasspath << project.sourceSets.main.runtimeClasspath javadocClasspath << "${buildDir}/generated/sources/annotationProcessor/java/main" javadocDependentTasks << project.tasks.compileJava } @@ -457,6 +457,8 @@ task javaIncrementalFormatApply { task javadoc(type: Javadoc) { source javadocSource classpath = files(javadocClasspath) + // Exclude the misbehaving generated-by-Soy Java files + exclude "**/*SoyInfo.java" destinationDir = file("${buildDir}/docs/javadoc") options.encoding = "UTF-8" // In a lot of places we don't write @return so suppress warnings about that. diff --git a/buildSrc/gradle/dependency-locks/compile.lockfile b/buildSrc/gradle/dependency-locks/compile.lockfile index 2b0920ae1..add05e4df 100644 --- a/buildSrc/gradle/dependency-locks/compile.lockfile +++ b/buildSrc/gradle/dependency-locks/compile.lockfile @@ -20,12 +20,12 @@ com.google.cloud:google-cloud-core:1.94.3 com.google.cloud:google-cloud-storage:1.113.12 com.google.code.findbugs:jsr305:3.0.2 com.google.code.gson:gson:2.8.6 -com.google.common.html.types:types:1.0.4 +com.google.common.html.types:types:1.0.6 com.google.errorprone:error_prone_annotations:2.5.1 +com.google.escapevelocity:escapevelocity:0.9.1 com.google.guava:failureaccess:1.0.1 com.google.guava:guava:30.1-jre com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava -com.google.gwt:gwt-user:2.8.0-beta1 com.google.http-client:google-http-client-apache-v2:1.39.0 com.google.http-client:google-http-client-appengine:1.39.0 com.google.http-client:google-http-client-gson:1.39.0 @@ -34,10 +34,11 @@ com.google.http-client:google-http-client:1.39.0 com.google.inject.extensions:guice-multibindings:4.1.0 com.google.inject:guice:4.1.0 com.google.j2objc:j2objc-annotations:1.3 +com.google.jsinterop:jsinterop-annotations:1.0.1 com.google.oauth-client:google-oauth-client:1.31.4 com.google.protobuf:protobuf-java-util:3.15.3 com.google.protobuf:protobuf-java:3.15.3 -com.google.template:soy:2018-03-14 +com.google.template:soy:2021-02-01 com.ibm.icu:icu4j:57.1 commons-codec:commons-codec:1.11 commons-logging:commons-logging:1.2 @@ -47,7 +48,6 @@ io.opencensus:opencensus-contrib-http-util:0.28.0 javax.annotation:javax.annotation-api:1.3.2 javax.annotation:jsr250-api:1.0 javax.inject:javax.inject:1 -javax.validation:validation-api:1.0.0.GA org.apache.commons:commons-lang3:3.8.1 org.apache.commons:commons-text:1.6 org.apache.httpcomponents:httpclient:4.5.13 @@ -55,9 +55,9 @@ org.apache.httpcomponents:httpcore:4.4.14 org.checkerframework:checker-compat-qual:2.5.5 org.checkerframework:checker-qual:3.5.0 org.json:json:20160212 -org.ow2.asm:asm-analysis:6.0 -org.ow2.asm:asm-commons:6.0 -org.ow2.asm:asm-tree:6.0 -org.ow2.asm:asm-util:6.0 -org.ow2.asm:asm:6.0 +org.ow2.asm:asm-analysis:7.0 +org.ow2.asm:asm-commons:7.0 +org.ow2.asm:asm-tree:7.0 +org.ow2.asm:asm-util:7.0 +org.ow2.asm:asm:7.0 org.threeten:threetenbp:1.5.0 diff --git a/buildSrc/gradle/dependency-locks/compileClasspath.lockfile b/buildSrc/gradle/dependency-locks/compileClasspath.lockfile index 2b0920ae1..add05e4df 100644 --- a/buildSrc/gradle/dependency-locks/compileClasspath.lockfile +++ b/buildSrc/gradle/dependency-locks/compileClasspath.lockfile @@ -20,12 +20,12 @@ com.google.cloud:google-cloud-core:1.94.3 com.google.cloud:google-cloud-storage:1.113.12 com.google.code.findbugs:jsr305:3.0.2 com.google.code.gson:gson:2.8.6 -com.google.common.html.types:types:1.0.4 +com.google.common.html.types:types:1.0.6 com.google.errorprone:error_prone_annotations:2.5.1 +com.google.escapevelocity:escapevelocity:0.9.1 com.google.guava:failureaccess:1.0.1 com.google.guava:guava:30.1-jre com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava -com.google.gwt:gwt-user:2.8.0-beta1 com.google.http-client:google-http-client-apache-v2:1.39.0 com.google.http-client:google-http-client-appengine:1.39.0 com.google.http-client:google-http-client-gson:1.39.0 @@ -34,10 +34,11 @@ com.google.http-client:google-http-client:1.39.0 com.google.inject.extensions:guice-multibindings:4.1.0 com.google.inject:guice:4.1.0 com.google.j2objc:j2objc-annotations:1.3 +com.google.jsinterop:jsinterop-annotations:1.0.1 com.google.oauth-client:google-oauth-client:1.31.4 com.google.protobuf:protobuf-java-util:3.15.3 com.google.protobuf:protobuf-java:3.15.3 -com.google.template:soy:2018-03-14 +com.google.template:soy:2021-02-01 com.ibm.icu:icu4j:57.1 commons-codec:commons-codec:1.11 commons-logging:commons-logging:1.2 @@ -47,7 +48,6 @@ io.opencensus:opencensus-contrib-http-util:0.28.0 javax.annotation:javax.annotation-api:1.3.2 javax.annotation:jsr250-api:1.0 javax.inject:javax.inject:1 -javax.validation:validation-api:1.0.0.GA org.apache.commons:commons-lang3:3.8.1 org.apache.commons:commons-text:1.6 org.apache.httpcomponents:httpclient:4.5.13 @@ -55,9 +55,9 @@ org.apache.httpcomponents:httpcore:4.4.14 org.checkerframework:checker-compat-qual:2.5.5 org.checkerframework:checker-qual:3.5.0 org.json:json:20160212 -org.ow2.asm:asm-analysis:6.0 -org.ow2.asm:asm-commons:6.0 -org.ow2.asm:asm-tree:6.0 -org.ow2.asm:asm-util:6.0 -org.ow2.asm:asm:6.0 +org.ow2.asm:asm-analysis:7.0 +org.ow2.asm:asm-commons:7.0 +org.ow2.asm:asm-tree:7.0 +org.ow2.asm:asm-util:7.0 +org.ow2.asm:asm:7.0 org.threeten:threetenbp:1.5.0 diff --git a/buildSrc/gradle/dependency-locks/deploy_jar.lockfile b/buildSrc/gradle/dependency-locks/deploy_jar.lockfile index 2b0920ae1..add05e4df 100644 --- a/buildSrc/gradle/dependency-locks/deploy_jar.lockfile +++ b/buildSrc/gradle/dependency-locks/deploy_jar.lockfile @@ -20,12 +20,12 @@ com.google.cloud:google-cloud-core:1.94.3 com.google.cloud:google-cloud-storage:1.113.12 com.google.code.findbugs:jsr305:3.0.2 com.google.code.gson:gson:2.8.6 -com.google.common.html.types:types:1.0.4 +com.google.common.html.types:types:1.0.6 com.google.errorprone:error_prone_annotations:2.5.1 +com.google.escapevelocity:escapevelocity:0.9.1 com.google.guava:failureaccess:1.0.1 com.google.guava:guava:30.1-jre com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava -com.google.gwt:gwt-user:2.8.0-beta1 com.google.http-client:google-http-client-apache-v2:1.39.0 com.google.http-client:google-http-client-appengine:1.39.0 com.google.http-client:google-http-client-gson:1.39.0 @@ -34,10 +34,11 @@ com.google.http-client:google-http-client:1.39.0 com.google.inject.extensions:guice-multibindings:4.1.0 com.google.inject:guice:4.1.0 com.google.j2objc:j2objc-annotations:1.3 +com.google.jsinterop:jsinterop-annotations:1.0.1 com.google.oauth-client:google-oauth-client:1.31.4 com.google.protobuf:protobuf-java-util:3.15.3 com.google.protobuf:protobuf-java:3.15.3 -com.google.template:soy:2018-03-14 +com.google.template:soy:2021-02-01 com.ibm.icu:icu4j:57.1 commons-codec:commons-codec:1.11 commons-logging:commons-logging:1.2 @@ -47,7 +48,6 @@ io.opencensus:opencensus-contrib-http-util:0.28.0 javax.annotation:javax.annotation-api:1.3.2 javax.annotation:jsr250-api:1.0 javax.inject:javax.inject:1 -javax.validation:validation-api:1.0.0.GA org.apache.commons:commons-lang3:3.8.1 org.apache.commons:commons-text:1.6 org.apache.httpcomponents:httpclient:4.5.13 @@ -55,9 +55,9 @@ org.apache.httpcomponents:httpcore:4.4.14 org.checkerframework:checker-compat-qual:2.5.5 org.checkerframework:checker-qual:3.5.0 org.json:json:20160212 -org.ow2.asm:asm-analysis:6.0 -org.ow2.asm:asm-commons:6.0 -org.ow2.asm:asm-tree:6.0 -org.ow2.asm:asm-util:6.0 -org.ow2.asm:asm:6.0 +org.ow2.asm:asm-analysis:7.0 +org.ow2.asm:asm-commons:7.0 +org.ow2.asm:asm-tree:7.0 +org.ow2.asm:asm-util:7.0 +org.ow2.asm:asm:7.0 org.threeten:threetenbp:1.5.0 diff --git a/buildSrc/gradle/dependency-locks/runtime.lockfile b/buildSrc/gradle/dependency-locks/runtime.lockfile index 2b0920ae1..add05e4df 100644 --- a/buildSrc/gradle/dependency-locks/runtime.lockfile +++ b/buildSrc/gradle/dependency-locks/runtime.lockfile @@ -20,12 +20,12 @@ com.google.cloud:google-cloud-core:1.94.3 com.google.cloud:google-cloud-storage:1.113.12 com.google.code.findbugs:jsr305:3.0.2 com.google.code.gson:gson:2.8.6 -com.google.common.html.types:types:1.0.4 +com.google.common.html.types:types:1.0.6 com.google.errorprone:error_prone_annotations:2.5.1 +com.google.escapevelocity:escapevelocity:0.9.1 com.google.guava:failureaccess:1.0.1 com.google.guava:guava:30.1-jre com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava -com.google.gwt:gwt-user:2.8.0-beta1 com.google.http-client:google-http-client-apache-v2:1.39.0 com.google.http-client:google-http-client-appengine:1.39.0 com.google.http-client:google-http-client-gson:1.39.0 @@ -34,10 +34,11 @@ com.google.http-client:google-http-client:1.39.0 com.google.inject.extensions:guice-multibindings:4.1.0 com.google.inject:guice:4.1.0 com.google.j2objc:j2objc-annotations:1.3 +com.google.jsinterop:jsinterop-annotations:1.0.1 com.google.oauth-client:google-oauth-client:1.31.4 com.google.protobuf:protobuf-java-util:3.15.3 com.google.protobuf:protobuf-java:3.15.3 -com.google.template:soy:2018-03-14 +com.google.template:soy:2021-02-01 com.ibm.icu:icu4j:57.1 commons-codec:commons-codec:1.11 commons-logging:commons-logging:1.2 @@ -47,7 +48,6 @@ io.opencensus:opencensus-contrib-http-util:0.28.0 javax.annotation:javax.annotation-api:1.3.2 javax.annotation:jsr250-api:1.0 javax.inject:javax.inject:1 -javax.validation:validation-api:1.0.0.GA org.apache.commons:commons-lang3:3.8.1 org.apache.commons:commons-text:1.6 org.apache.httpcomponents:httpclient:4.5.13 @@ -55,9 +55,9 @@ org.apache.httpcomponents:httpcore:4.4.14 org.checkerframework:checker-compat-qual:2.5.5 org.checkerframework:checker-qual:3.5.0 org.json:json:20160212 -org.ow2.asm:asm-analysis:6.0 -org.ow2.asm:asm-commons:6.0 -org.ow2.asm:asm-tree:6.0 -org.ow2.asm:asm-util:6.0 -org.ow2.asm:asm:6.0 +org.ow2.asm:asm-analysis:7.0 +org.ow2.asm:asm-commons:7.0 +org.ow2.asm:asm-tree:7.0 +org.ow2.asm:asm-util:7.0 +org.ow2.asm:asm:7.0 org.threeten:threetenbp:1.5.0 diff --git a/buildSrc/gradle/dependency-locks/runtimeClasspath.lockfile b/buildSrc/gradle/dependency-locks/runtimeClasspath.lockfile index 2b0920ae1..add05e4df 100644 --- a/buildSrc/gradle/dependency-locks/runtimeClasspath.lockfile +++ b/buildSrc/gradle/dependency-locks/runtimeClasspath.lockfile @@ -20,12 +20,12 @@ com.google.cloud:google-cloud-core:1.94.3 com.google.cloud:google-cloud-storage:1.113.12 com.google.code.findbugs:jsr305:3.0.2 com.google.code.gson:gson:2.8.6 -com.google.common.html.types:types:1.0.4 +com.google.common.html.types:types:1.0.6 com.google.errorprone:error_prone_annotations:2.5.1 +com.google.escapevelocity:escapevelocity:0.9.1 com.google.guava:failureaccess:1.0.1 com.google.guava:guava:30.1-jre com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava -com.google.gwt:gwt-user:2.8.0-beta1 com.google.http-client:google-http-client-apache-v2:1.39.0 com.google.http-client:google-http-client-appengine:1.39.0 com.google.http-client:google-http-client-gson:1.39.0 @@ -34,10 +34,11 @@ com.google.http-client:google-http-client:1.39.0 com.google.inject.extensions:guice-multibindings:4.1.0 com.google.inject:guice:4.1.0 com.google.j2objc:j2objc-annotations:1.3 +com.google.jsinterop:jsinterop-annotations:1.0.1 com.google.oauth-client:google-oauth-client:1.31.4 com.google.protobuf:protobuf-java-util:3.15.3 com.google.protobuf:protobuf-java:3.15.3 -com.google.template:soy:2018-03-14 +com.google.template:soy:2021-02-01 com.ibm.icu:icu4j:57.1 commons-codec:commons-codec:1.11 commons-logging:commons-logging:1.2 @@ -47,7 +48,6 @@ io.opencensus:opencensus-contrib-http-util:0.28.0 javax.annotation:javax.annotation-api:1.3.2 javax.annotation:jsr250-api:1.0 javax.inject:javax.inject:1 -javax.validation:validation-api:1.0.0.GA org.apache.commons:commons-lang3:3.8.1 org.apache.commons:commons-text:1.6 org.apache.httpcomponents:httpclient:4.5.13 @@ -55,9 +55,9 @@ org.apache.httpcomponents:httpcore:4.4.14 org.checkerframework:checker-compat-qual:2.5.5 org.checkerframework:checker-qual:3.5.0 org.json:json:20160212 -org.ow2.asm:asm-analysis:6.0 -org.ow2.asm:asm-commons:6.0 -org.ow2.asm:asm-tree:6.0 -org.ow2.asm:asm-util:6.0 -org.ow2.asm:asm:6.0 +org.ow2.asm:asm-analysis:7.0 +org.ow2.asm:asm-commons:7.0 +org.ow2.asm:asm-tree:7.0 +org.ow2.asm:asm-util:7.0 +org.ow2.asm:asm:7.0 org.threeten:threetenbp:1.5.0 diff --git a/buildSrc/gradle/dependency-locks/testCompile.lockfile b/buildSrc/gradle/dependency-locks/testCompile.lockfile index 85a2d72f9..ddd2b2326 100644 --- a/buildSrc/gradle/dependency-locks/testCompile.lockfile +++ b/buildSrc/gradle/dependency-locks/testCompile.lockfile @@ -20,12 +20,12 @@ com.google.cloud:google-cloud-core:1.94.3 com.google.cloud:google-cloud-storage:1.113.12 com.google.code.findbugs:jsr305:3.0.2 com.google.code.gson:gson:2.8.6 -com.google.common.html.types:types:1.0.4 +com.google.common.html.types:types:1.0.6 com.google.errorprone:error_prone_annotations:2.5.1 +com.google.escapevelocity:escapevelocity:0.9.1 com.google.guava:failureaccess:1.0.1 com.google.guava:guava:30.1-jre com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava -com.google.gwt:gwt-user:2.8.0-beta1 com.google.http-client:google-http-client-apache-v2:1.39.0 com.google.http-client:google-http-client-appengine:1.39.0 com.google.http-client:google-http-client-gson:1.39.0 @@ -34,10 +34,11 @@ com.google.http-client:google-http-client:1.39.0 com.google.inject.extensions:guice-multibindings:4.1.0 com.google.inject:guice:4.1.0 com.google.j2objc:j2objc-annotations:1.3 +com.google.jsinterop:jsinterop-annotations:1.0.1 com.google.oauth-client:google-oauth-client:1.31.4 com.google.protobuf:protobuf-java-util:3.15.3 com.google.protobuf:protobuf-java:3.15.3 -com.google.template:soy:2018-03-14 +com.google.template:soy:2021-02-01 com.google.truth.extensions:truth-java8-extension:1.1.2 com.google.truth:truth:1.1.2 com.ibm.icu:icu4j:57.1 @@ -49,7 +50,6 @@ io.opencensus:opencensus-contrib-http-util:0.28.0 javax.annotation:javax.annotation-api:1.3.2 javax.annotation:jsr250-api:1.0 javax.inject:javax.inject:1 -javax.validation:validation-api:1.0.0.GA junit:junit:4.13.1 net.bytebuddy:byte-buddy-agent:1.10.19 net.bytebuddy:byte-buddy:1.10.19 @@ -70,9 +70,9 @@ org.junit:junit-bom:5.6.2 org.mockito:mockito-core:3.7.7 org.objenesis:objenesis:3.1 org.opentest4j:opentest4j:1.2.0 -org.ow2.asm:asm-analysis:6.0 -org.ow2.asm:asm-commons:6.0 -org.ow2.asm:asm-tree:6.0 -org.ow2.asm:asm-util:6.0 +org.ow2.asm:asm-analysis:7.0 +org.ow2.asm:asm-commons:7.0 +org.ow2.asm:asm-tree:7.0 +org.ow2.asm:asm-util:7.0 org.ow2.asm:asm:9.0 org.threeten:threetenbp:1.5.0 diff --git a/buildSrc/gradle/dependency-locks/testCompileClasspath.lockfile b/buildSrc/gradle/dependency-locks/testCompileClasspath.lockfile index 85a2d72f9..ddd2b2326 100644 --- a/buildSrc/gradle/dependency-locks/testCompileClasspath.lockfile +++ b/buildSrc/gradle/dependency-locks/testCompileClasspath.lockfile @@ -20,12 +20,12 @@ com.google.cloud:google-cloud-core:1.94.3 com.google.cloud:google-cloud-storage:1.113.12 com.google.code.findbugs:jsr305:3.0.2 com.google.code.gson:gson:2.8.6 -com.google.common.html.types:types:1.0.4 +com.google.common.html.types:types:1.0.6 com.google.errorprone:error_prone_annotations:2.5.1 +com.google.escapevelocity:escapevelocity:0.9.1 com.google.guava:failureaccess:1.0.1 com.google.guava:guava:30.1-jre com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava -com.google.gwt:gwt-user:2.8.0-beta1 com.google.http-client:google-http-client-apache-v2:1.39.0 com.google.http-client:google-http-client-appengine:1.39.0 com.google.http-client:google-http-client-gson:1.39.0 @@ -34,10 +34,11 @@ com.google.http-client:google-http-client:1.39.0 com.google.inject.extensions:guice-multibindings:4.1.0 com.google.inject:guice:4.1.0 com.google.j2objc:j2objc-annotations:1.3 +com.google.jsinterop:jsinterop-annotations:1.0.1 com.google.oauth-client:google-oauth-client:1.31.4 com.google.protobuf:protobuf-java-util:3.15.3 com.google.protobuf:protobuf-java:3.15.3 -com.google.template:soy:2018-03-14 +com.google.template:soy:2021-02-01 com.google.truth.extensions:truth-java8-extension:1.1.2 com.google.truth:truth:1.1.2 com.ibm.icu:icu4j:57.1 @@ -49,7 +50,6 @@ io.opencensus:opencensus-contrib-http-util:0.28.0 javax.annotation:javax.annotation-api:1.3.2 javax.annotation:jsr250-api:1.0 javax.inject:javax.inject:1 -javax.validation:validation-api:1.0.0.GA junit:junit:4.13.1 net.bytebuddy:byte-buddy-agent:1.10.19 net.bytebuddy:byte-buddy:1.10.19 @@ -70,9 +70,9 @@ org.junit:junit-bom:5.6.2 org.mockito:mockito-core:3.7.7 org.objenesis:objenesis:3.1 org.opentest4j:opentest4j:1.2.0 -org.ow2.asm:asm-analysis:6.0 -org.ow2.asm:asm-commons:6.0 -org.ow2.asm:asm-tree:6.0 -org.ow2.asm:asm-util:6.0 +org.ow2.asm:asm-analysis:7.0 +org.ow2.asm:asm-commons:7.0 +org.ow2.asm:asm-tree:7.0 +org.ow2.asm:asm-util:7.0 org.ow2.asm:asm:9.0 org.threeten:threetenbp:1.5.0 diff --git a/buildSrc/gradle/dependency-locks/testRuntime.lockfile b/buildSrc/gradle/dependency-locks/testRuntime.lockfile index 85a2d72f9..ddd2b2326 100644 --- a/buildSrc/gradle/dependency-locks/testRuntime.lockfile +++ b/buildSrc/gradle/dependency-locks/testRuntime.lockfile @@ -20,12 +20,12 @@ com.google.cloud:google-cloud-core:1.94.3 com.google.cloud:google-cloud-storage:1.113.12 com.google.code.findbugs:jsr305:3.0.2 com.google.code.gson:gson:2.8.6 -com.google.common.html.types:types:1.0.4 +com.google.common.html.types:types:1.0.6 com.google.errorprone:error_prone_annotations:2.5.1 +com.google.escapevelocity:escapevelocity:0.9.1 com.google.guava:failureaccess:1.0.1 com.google.guava:guava:30.1-jre com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava -com.google.gwt:gwt-user:2.8.0-beta1 com.google.http-client:google-http-client-apache-v2:1.39.0 com.google.http-client:google-http-client-appengine:1.39.0 com.google.http-client:google-http-client-gson:1.39.0 @@ -34,10 +34,11 @@ com.google.http-client:google-http-client:1.39.0 com.google.inject.extensions:guice-multibindings:4.1.0 com.google.inject:guice:4.1.0 com.google.j2objc:j2objc-annotations:1.3 +com.google.jsinterop:jsinterop-annotations:1.0.1 com.google.oauth-client:google-oauth-client:1.31.4 com.google.protobuf:protobuf-java-util:3.15.3 com.google.protobuf:protobuf-java:3.15.3 -com.google.template:soy:2018-03-14 +com.google.template:soy:2021-02-01 com.google.truth.extensions:truth-java8-extension:1.1.2 com.google.truth:truth:1.1.2 com.ibm.icu:icu4j:57.1 @@ -49,7 +50,6 @@ io.opencensus:opencensus-contrib-http-util:0.28.0 javax.annotation:javax.annotation-api:1.3.2 javax.annotation:jsr250-api:1.0 javax.inject:javax.inject:1 -javax.validation:validation-api:1.0.0.GA junit:junit:4.13.1 net.bytebuddy:byte-buddy-agent:1.10.19 net.bytebuddy:byte-buddy:1.10.19 @@ -70,9 +70,9 @@ org.junit:junit-bom:5.6.2 org.mockito:mockito-core:3.7.7 org.objenesis:objenesis:3.1 org.opentest4j:opentest4j:1.2.0 -org.ow2.asm:asm-analysis:6.0 -org.ow2.asm:asm-commons:6.0 -org.ow2.asm:asm-tree:6.0 -org.ow2.asm:asm-util:6.0 +org.ow2.asm:asm-analysis:7.0 +org.ow2.asm:asm-commons:7.0 +org.ow2.asm:asm-tree:7.0 +org.ow2.asm:asm-util:7.0 org.ow2.asm:asm:9.0 org.threeten:threetenbp:1.5.0 diff --git a/buildSrc/gradle/dependency-locks/testRuntimeClasspath.lockfile b/buildSrc/gradle/dependency-locks/testRuntimeClasspath.lockfile index 85a2d72f9..ddd2b2326 100644 --- a/buildSrc/gradle/dependency-locks/testRuntimeClasspath.lockfile +++ b/buildSrc/gradle/dependency-locks/testRuntimeClasspath.lockfile @@ -20,12 +20,12 @@ com.google.cloud:google-cloud-core:1.94.3 com.google.cloud:google-cloud-storage:1.113.12 com.google.code.findbugs:jsr305:3.0.2 com.google.code.gson:gson:2.8.6 -com.google.common.html.types:types:1.0.4 +com.google.common.html.types:types:1.0.6 com.google.errorprone:error_prone_annotations:2.5.1 +com.google.escapevelocity:escapevelocity:0.9.1 com.google.guava:failureaccess:1.0.1 com.google.guava:guava:30.1-jre com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava -com.google.gwt:gwt-user:2.8.0-beta1 com.google.http-client:google-http-client-apache-v2:1.39.0 com.google.http-client:google-http-client-appengine:1.39.0 com.google.http-client:google-http-client-gson:1.39.0 @@ -34,10 +34,11 @@ com.google.http-client:google-http-client:1.39.0 com.google.inject.extensions:guice-multibindings:4.1.0 com.google.inject:guice:4.1.0 com.google.j2objc:j2objc-annotations:1.3 +com.google.jsinterop:jsinterop-annotations:1.0.1 com.google.oauth-client:google-oauth-client:1.31.4 com.google.protobuf:protobuf-java-util:3.15.3 com.google.protobuf:protobuf-java:3.15.3 -com.google.template:soy:2018-03-14 +com.google.template:soy:2021-02-01 com.google.truth.extensions:truth-java8-extension:1.1.2 com.google.truth:truth:1.1.2 com.ibm.icu:icu4j:57.1 @@ -49,7 +50,6 @@ io.opencensus:opencensus-contrib-http-util:0.28.0 javax.annotation:javax.annotation-api:1.3.2 javax.annotation:jsr250-api:1.0 javax.inject:javax.inject:1 -javax.validation:validation-api:1.0.0.GA junit:junit:4.13.1 net.bytebuddy:byte-buddy-agent:1.10.19 net.bytebuddy:byte-buddy:1.10.19 @@ -70,9 +70,9 @@ org.junit:junit-bom:5.6.2 org.mockito:mockito-core:3.7.7 org.objenesis:objenesis:3.1 org.opentest4j:opentest4j:1.2.0 -org.ow2.asm:asm-analysis:6.0 -org.ow2.asm:asm-commons:6.0 -org.ow2.asm:asm-tree:6.0 -org.ow2.asm:asm-util:6.0 +org.ow2.asm:asm-analysis:7.0 +org.ow2.asm:asm-commons:7.0 +org.ow2.asm:asm-tree:7.0 +org.ow2.asm:asm-util:7.0 org.ow2.asm:asm:9.0 org.threeten:threetenbp:1.5.0 diff --git a/buildSrc/src/main/java/google/registry/gradle/plugin/CoverPageGenerator.java b/buildSrc/src/main/java/google/registry/gradle/plugin/CoverPageGenerator.java index dca7d82d1..e316cf976 100644 --- a/buildSrc/src/main/java/google/registry/gradle/plugin/CoverPageGenerator.java +++ b/buildSrc/src/main/java/google/registry/gradle/plugin/CoverPageGenerator.java @@ -23,6 +23,7 @@ import static google.registry.gradle.plugin.GcsPluginUtils.toByteArraySupplier; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSetMultimap; +import com.google.common.html.types.TrustedResourceUrls; import com.google.template.soy.SoyFileSet; import com.google.template.soy.tofu.SoyTofu; import google.registry.gradle.plugin.ProjectData.TaskData; @@ -118,7 +119,7 @@ final class CoverPageGenerator { builder.put("projectState", state.toString()); builder.put("title", title); - builder.put("cssFiles", ImmutableSet.of("css/style.css")); + builder.put("cssFiles", ImmutableSet.of(TrustedResourceUrls.fromConstant("css/style.css"))); builder.put("invocation", getInvocation()); builder.put("tasksByState", getTasksByStateSoyData()); return builder.build(); diff --git a/buildSrc/src/main/resources/google/registry/gradle/plugin/soy/coverpage.soy b/buildSrc/src/main/resources/google/registry/gradle/plugin/soy/coverpage.soy index 2de8c17a1..30eb5083b 100644 --- a/buildSrc/src/main/resources/google/registry/gradle/plugin/soy/coverpage.soy +++ b/buildSrc/src/main/resources/google/registry/gradle/plugin/soy/coverpage.soy @@ -16,7 +16,7 @@ {template .coverPage} {@param title: string} - {@param cssFiles: list} + {@param cssFiles: list} {@param projectState: string} {@param invocation: string} {@param tasksByState: map]>>} diff --git a/config/presubmits.py b/config/presubmits.py index c4a9c9496..7efdd4f80 100644 --- a/config/presubmits.py +++ b/config/presubmits.py @@ -81,7 +81,7 @@ PRESUBMITS = { ".git", "/build/", "/generated/", "/generated_tests/", "node_modules/", "JUnitBackports.java", "registrar_bin.", "registrar_dbg.", "google-java-format-diff.py", - "nomulus.golden.sql", "soyutils_usegoog.js" + "nomulus.golden.sql", "soyutils_usegoog.js", "javascript/checks.js" }, REQUIRED): "File did not include the license header.", diff --git a/core/build.gradle b/core/build.gradle index d0c1a5358..62f95fbd6 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -433,12 +433,9 @@ task soyToJava { // Relative paths of soy directories. def spec11SoyDir = "google/registry/reporting/spec11/soy" def toolsSoyDir = "google/registry/tools/soy" - def uiSoyDir = "google/registry/ui/soy" def registrarSoyDir = "google/registry/ui/soy/registrar" - def soyRelativeDirs = [ - spec11SoyDir, toolsSoyDir, uiSoyDir, registrarSoyDir, - ] + def soyRelativeDirs = [spec11SoyDir, toolsSoyDir, registrarSoyDir] soyRelativeDirs.each { inputs.dir "${resourcesSourceDir}/${it}" outputs.dir "${generatedDir}/${it}" @@ -452,7 +449,8 @@ task soyToJava { "--outputDirectory", "${outputDirectory}", "--javaClassNameSource", "filename", "--allowExternalCalls", "true", - "--srcs", "${soyFiles.join(',')}" + "--srcs", "${soyFiles.join(',')}", + "--compileTimeGlobalsFile", "${resourcesSourceDir}/google/registry/ui/globals.txt" } } @@ -469,14 +467,6 @@ task soyToJava { dir: "${resourcesSourceDir}/${registrarSoyDir}", include: ['**/*.soy'])) - soyToJava('google.registry.ui.soy', - "${generatedDir}/${uiSoyDir}", - files { - file("${resourcesSourceDir}/${uiSoyDir}").listFiles() - }.filter { - it.name.endsWith(".soy") - }) - soyToJava('google.registry.reporting.spec11.soy', "${generatedDir}/${spec11SoyDir}", fileTree( @@ -485,42 +475,24 @@ task soyToJava { } } -task soyToJS { - def rootSoyDirectory = "${resourcesSourceDir}/google/registry/ui/soy" - def outputSoyDirectory = "${generatedDir}/google/registry/ui/soy" +task soyToJS(type: JavaExec) { + def rootSoyDirectory = "${resourcesSourceDir}/google/registry/ui/soy/registrar" + def outputSoyDirectory = "${generatedDir}/google/registry/ui/soy/registrar" inputs.dir rootSoyDirectory outputs.dir outputSoyDirectory - ext.soyToJS = { outputDirectory, soyFiles , deps-> - javaexec { - main = "com.google.template.soy.SoyToJsSrcCompiler" - classpath configurations.soy + def inputSoyFiles = files { + file("${rootSoyDirectory}").listFiles() + }.filter { + it.name.endsWith(".soy") + } - args "--outputPathFormat", "${outputDirectory}/{INPUT_FILE_NAME}.js", + classpath configurations.soy + main = "com.google.template.soy.SoyToJsSrcCompiler" + args "--outputPathFormat", "${outputSoyDirectory}/{INPUT_FILE_NAME}.js", "--allowExternalCalls", "false", - "--srcs", "${soyFiles.join(',')}", - "--shouldProvideRequireSoyNamespaces", "true", + "--srcs", "${inputSoyFiles.join(',')}", "--compileTimeGlobalsFile", "${resourcesSourceDir}/google/registry/ui/globals.txt" - if (deps != "") { - args "--deps", "${deps.join(',')}" - } - } - } - - doLast { - def rootSoyFiles = - fileTree( - dir: "${rootSoyDirectory}", - include: ['*.soy']) - - soyToJS("${outputSoyDirectory}", rootSoyFiles, "") - soyToJS("${outputSoyDirectory}/registrar", - files { - file("${rootSoyDirectory}/registrar").listFiles() - }.filter { - it.name.endsWith(".soy") - }, rootSoyFiles) - } } task stylesheetsToJavascript { @@ -603,8 +575,8 @@ task compileProdJS(type: JavaExec) { closureArgs << "--generate_exports" // manually include all the required js files - closureArgs << "--js=${nodeModulesDir}/google-closure-library/**.js" - closureArgs << "--js=${jsDir}/soyutils_usegoog.js" + closureArgs << "--js=${nodeModulesDir}/google-closure-library/**/*.js" + closureArgs << "--js=${jsDir}/*.js" closureArgs << "--js=${cssSourceDir}/registrar_bin.css.js" closureArgs << "--js=${jsSourceDir}/**.js" closureArgs << "--js=${externsDir}/json.js" @@ -631,15 +603,6 @@ compileProdJS.dependsOn processResources compileProdJS.dependsOn processTestResources compileProdJS.dependsOn soyToJS -task karmaTest(type: Exec) { - dependsOn ':npmInstall' - workingDir rootProject.projectDir - executable '.gradle/nodejs/node-v14.15.5-linux-x64/bin/node' - args('node_modules/karma/bin/karma', 'start', "${project.projectDir}/karma.conf.js") -} - -test.dependsOn karmaTest - // Make testing artifacts available to be depended up on by other projects. // TODO: factor out google.registry.testing to be a separate project. task testJar(type: Jar) { diff --git a/core/gradle/dependency-locks/closureCompiler.lockfile b/core/gradle/dependency-locks/closureCompiler.lockfile index 6d2aec8d5..0fe333f72 100644 --- a/core/gradle/dependency-locks/closureCompiler.lockfile +++ b/core/gradle/dependency-locks/closureCompiler.lockfile @@ -1,15 +1,4 @@ # This is a Gradle generated file for dependency locking. # Manual edits can break the build and are not advised. # This file is expected to be part of source control. -args4j:args4j:2.0.26 -com.google.code.findbugs:jsr305:3.0.2 -com.google.code.gson:gson:2.7 -com.google.errorprone:error_prone_annotations:2.3.1 -com.google.guava:guava:25.1-jre -com.google.j2objc:j2objc-annotations:1.1 -com.google.javascript:closure-compiler-externs:v20190301 -com.google.javascript:closure-compiler:v20190301 -com.google.jsinterop:jsinterop-annotations:1.0.0 -com.google.protobuf:protobuf-java:3.0.2 -org.checkerframework:checker-qual:2.0.0 -org.codehaus.mojo:animal-sniffer-annotations:1.14 +com.google.javascript:closure-compiler:v20210505 diff --git a/core/gradle/dependency-locks/compile.lockfile b/core/gradle/dependency-locks/compile.lockfile index 2de8d033c..e3e31a555 100644 --- a/core/gradle/dependency-locks/compile.lockfile +++ b/core/gradle/dependency-locks/compile.lockfile @@ -105,9 +105,10 @@ com.google.cloud:google-cloud-secretmanager:1.4.0 com.google.cloud:google-cloud-spanner:2.0.2 com.google.code.findbugs:jsr305:3.0.2 com.google.code.gson:gson:2.8.6 -com.google.common.html.types:types:1.0.4 +com.google.common.html.types:types:1.0.6 com.google.dagger:dagger:2.33 com.google.errorprone:error_prone_annotations:2.5.1 +com.google.escapevelocity:escapevelocity:0.9.1 com.google.flogger:flogger-system-backend:0.5.1 com.google.flogger:flogger:0.5.1 com.google.flogger:google-extensions:0.5.1 @@ -135,7 +136,7 @@ com.google.oauth-client:google-oauth-client:1.31.4 com.google.protobuf:protobuf-java-util:3.15.2 com.google.protobuf:protobuf-java:3.15.2 com.google.re2j:re2j:1.6 -com.google.template:soy:2018-03-14 +com.google.template:soy:2021-02-01 com.googlecode.charts4j:charts4j:1.3 com.googlecode.json-simple:json-simple:1.1.1 com.ibm.icu:icu4j:68.2 diff --git a/core/gradle/dependency-locks/compileClasspath.lockfile b/core/gradle/dependency-locks/compileClasspath.lockfile index 3143180a1..80864edca 100644 --- a/core/gradle/dependency-locks/compileClasspath.lockfile +++ b/core/gradle/dependency-locks/compileClasspath.lockfile @@ -104,9 +104,10 @@ com.google.cloud:google-cloud-secretmanager:1.4.0 com.google.cloud:google-cloud-spanner:2.0.2 com.google.code.findbugs:jsr305:3.0.2 com.google.code.gson:gson:2.8.6 -com.google.common.html.types:types:1.0.4 +com.google.common.html.types:types:1.0.6 com.google.dagger:dagger:2.33 com.google.errorprone:error_prone_annotations:2.5.1 +com.google.escapevelocity:escapevelocity:0.9.1 com.google.flogger:flogger:0.5.1 com.google.flogger:google-extensions:0.5.1 com.google.guava:failureaccess:1.0.1 @@ -133,7 +134,7 @@ com.google.oauth-client:google-oauth-client:1.31.4 com.google.protobuf:protobuf-java-util:3.14.0 com.google.protobuf:protobuf-java:3.15.2 com.google.re2j:re2j:1.6 -com.google.template:soy:2018-03-14 +com.google.template:soy:2021-02-01 com.googlecode.charts4j:charts4j:1.3 com.googlecode.json-simple:json-simple:1.1.1 com.ibm.icu:icu4j:68.2 diff --git a/core/gradle/dependency-locks/default.lockfile b/core/gradle/dependency-locks/default.lockfile index 02a41b6f2..350bc7d70 100644 --- a/core/gradle/dependency-locks/default.lockfile +++ b/core/gradle/dependency-locks/default.lockfile @@ -110,9 +110,10 @@ com.google.cloud:google-cloud-secretmanager:1.4.0 com.google.cloud:google-cloud-spanner:2.0.2 com.google.code.findbugs:jsr305:3.0.2 com.google.code.gson:gson:2.8.6 -com.google.common.html.types:types:1.0.4 +com.google.common.html.types:types:1.0.6 com.google.dagger:dagger:2.33 com.google.errorprone:error_prone_annotations:2.5.1 +com.google.escapevelocity:escapevelocity:0.9.1 com.google.flogger:flogger-system-backend:0.5.1 com.google.flogger:flogger:0.5.1 com.google.flogger:google-extensions:0.5.1 @@ -140,7 +141,7 @@ com.google.oauth-client:google-oauth-client:1.31.4 com.google.protobuf:protobuf-java-util:3.15.2 com.google.protobuf:protobuf-java:3.15.2 com.google.re2j:re2j:1.6 -com.google.template:soy:2018-03-14 +com.google.template:soy:2021-02-01 com.googlecode.charts4j:charts4j:1.3 com.googlecode.json-simple:json-simple:1.1.1 com.ibm.icu:icu4j:68.2 diff --git a/core/gradle/dependency-locks/deploy_jar.lockfile b/core/gradle/dependency-locks/deploy_jar.lockfile index 9e3ec7b3c..d67debded 100644 --- a/core/gradle/dependency-locks/deploy_jar.lockfile +++ b/core/gradle/dependency-locks/deploy_jar.lockfile @@ -110,9 +110,10 @@ com.google.cloud:google-cloud-secretmanager:1.4.0 com.google.cloud:google-cloud-spanner:2.0.2 com.google.code.findbugs:jsr305:3.0.2 com.google.code.gson:gson:2.8.6 -com.google.common.html.types:types:1.0.4 +com.google.common.html.types:types:1.0.6 com.google.dagger:dagger:2.33 com.google.errorprone:error_prone_annotations:2.5.1 +com.google.escapevelocity:escapevelocity:0.9.1 com.google.flogger:flogger-system-backend:0.5.1 com.google.flogger:flogger:0.5.1 com.google.flogger:google-extensions:0.5.1 @@ -140,7 +141,7 @@ com.google.oauth-client:google-oauth-client:1.31.4 com.google.protobuf:protobuf-java-util:3.15.2 com.google.protobuf:protobuf-java:3.15.2 com.google.re2j:re2j:1.6 -com.google.template:soy:2018-03-14 +com.google.template:soy:2021-02-01 com.googlecode.charts4j:charts4j:1.3 com.googlecode.json-simple:json-simple:1.1.1 com.ibm.icu:icu4j:68.2 diff --git a/core/gradle/dependency-locks/nonprodCompile.lockfile b/core/gradle/dependency-locks/nonprodCompile.lockfile index 2de8d033c..e3e31a555 100644 --- a/core/gradle/dependency-locks/nonprodCompile.lockfile +++ b/core/gradle/dependency-locks/nonprodCompile.lockfile @@ -105,9 +105,10 @@ com.google.cloud:google-cloud-secretmanager:1.4.0 com.google.cloud:google-cloud-spanner:2.0.2 com.google.code.findbugs:jsr305:3.0.2 com.google.code.gson:gson:2.8.6 -com.google.common.html.types:types:1.0.4 +com.google.common.html.types:types:1.0.6 com.google.dagger:dagger:2.33 com.google.errorprone:error_prone_annotations:2.5.1 +com.google.escapevelocity:escapevelocity:0.9.1 com.google.flogger:flogger-system-backend:0.5.1 com.google.flogger:flogger:0.5.1 com.google.flogger:google-extensions:0.5.1 @@ -135,7 +136,7 @@ com.google.oauth-client:google-oauth-client:1.31.4 com.google.protobuf:protobuf-java-util:3.15.2 com.google.protobuf:protobuf-java:3.15.2 com.google.re2j:re2j:1.6 -com.google.template:soy:2018-03-14 +com.google.template:soy:2021-02-01 com.googlecode.charts4j:charts4j:1.3 com.googlecode.json-simple:json-simple:1.1.1 com.ibm.icu:icu4j:68.2 diff --git a/core/gradle/dependency-locks/nonprodCompileClasspath.lockfile b/core/gradle/dependency-locks/nonprodCompileClasspath.lockfile index 975c2c807..70618ba77 100644 --- a/core/gradle/dependency-locks/nonprodCompileClasspath.lockfile +++ b/core/gradle/dependency-locks/nonprodCompileClasspath.lockfile @@ -104,9 +104,10 @@ com.google.cloud:google-cloud-secretmanager:1.4.0 com.google.cloud:google-cloud-spanner:2.0.2 com.google.code.findbugs:jsr305:3.0.2 com.google.code.gson:gson:2.8.6 -com.google.common.html.types:types:1.0.4 +com.google.common.html.types:types:1.0.6 com.google.dagger:dagger:2.33 com.google.errorprone:error_prone_annotations:2.5.1 +com.google.escapevelocity:escapevelocity:0.9.1 com.google.flogger:flogger:0.5.1 com.google.flogger:google-extensions:0.5.1 com.google.guava:failureaccess:1.0.1 @@ -133,7 +134,7 @@ com.google.oauth-client:google-oauth-client:1.31.4 com.google.protobuf:protobuf-java-util:3.14.0 com.google.protobuf:protobuf-java:3.15.2 com.google.re2j:re2j:1.6 -com.google.template:soy:2018-03-14 +com.google.template:soy:2021-02-01 com.googlecode.charts4j:charts4j:1.3 com.googlecode.json-simple:json-simple:1.1.1 com.ibm.icu:icu4j:68.2 diff --git a/core/gradle/dependency-locks/nonprodRuntime.lockfile b/core/gradle/dependency-locks/nonprodRuntime.lockfile index b36793dcb..36adf8801 100644 --- a/core/gradle/dependency-locks/nonprodRuntime.lockfile +++ b/core/gradle/dependency-locks/nonprodRuntime.lockfile @@ -109,9 +109,10 @@ com.google.cloud:google-cloud-secretmanager:1.4.0 com.google.cloud:google-cloud-spanner:2.0.2 com.google.code.findbugs:jsr305:3.0.2 com.google.code.gson:gson:2.8.6 -com.google.common.html.types:types:1.0.4 +com.google.common.html.types:types:1.0.6 com.google.dagger:dagger:2.33 com.google.errorprone:error_prone_annotations:2.5.1 +com.google.escapevelocity:escapevelocity:0.9.1 com.google.flogger:flogger-system-backend:0.5.1 com.google.flogger:flogger:0.5.1 com.google.flogger:google-extensions:0.5.1 @@ -139,7 +140,7 @@ com.google.oauth-client:google-oauth-client:1.31.4 com.google.protobuf:protobuf-java-util:3.15.2 com.google.protobuf:protobuf-java:3.15.2 com.google.re2j:re2j:1.6 -com.google.template:soy:2018-03-14 +com.google.template:soy:2021-02-01 com.googlecode.charts4j:charts4j:1.3 com.googlecode.json-simple:json-simple:1.1.1 com.ibm.icu:icu4j:68.2 diff --git a/core/gradle/dependency-locks/nonprodRuntimeClasspath.lockfile b/core/gradle/dependency-locks/nonprodRuntimeClasspath.lockfile index b36793dcb..36adf8801 100644 --- a/core/gradle/dependency-locks/nonprodRuntimeClasspath.lockfile +++ b/core/gradle/dependency-locks/nonprodRuntimeClasspath.lockfile @@ -109,9 +109,10 @@ com.google.cloud:google-cloud-secretmanager:1.4.0 com.google.cloud:google-cloud-spanner:2.0.2 com.google.code.findbugs:jsr305:3.0.2 com.google.code.gson:gson:2.8.6 -com.google.common.html.types:types:1.0.4 +com.google.common.html.types:types:1.0.6 com.google.dagger:dagger:2.33 com.google.errorprone:error_prone_annotations:2.5.1 +com.google.escapevelocity:escapevelocity:0.9.1 com.google.flogger:flogger-system-backend:0.5.1 com.google.flogger:flogger:0.5.1 com.google.flogger:google-extensions:0.5.1 @@ -139,7 +140,7 @@ com.google.oauth-client:google-oauth-client:1.31.4 com.google.protobuf:protobuf-java-util:3.15.2 com.google.protobuf:protobuf-java:3.15.2 com.google.re2j:re2j:1.6 -com.google.template:soy:2018-03-14 +com.google.template:soy:2021-02-01 com.googlecode.charts4j:charts4j:1.3 com.googlecode.json-simple:json-simple:1.1.1 com.ibm.icu:icu4j:68.2 diff --git a/core/gradle/dependency-locks/runtime.lockfile b/core/gradle/dependency-locks/runtime.lockfile index b36793dcb..36adf8801 100644 --- a/core/gradle/dependency-locks/runtime.lockfile +++ b/core/gradle/dependency-locks/runtime.lockfile @@ -109,9 +109,10 @@ com.google.cloud:google-cloud-secretmanager:1.4.0 com.google.cloud:google-cloud-spanner:2.0.2 com.google.code.findbugs:jsr305:3.0.2 com.google.code.gson:gson:2.8.6 -com.google.common.html.types:types:1.0.4 +com.google.common.html.types:types:1.0.6 com.google.dagger:dagger:2.33 com.google.errorprone:error_prone_annotations:2.5.1 +com.google.escapevelocity:escapevelocity:0.9.1 com.google.flogger:flogger-system-backend:0.5.1 com.google.flogger:flogger:0.5.1 com.google.flogger:google-extensions:0.5.1 @@ -139,7 +140,7 @@ com.google.oauth-client:google-oauth-client:1.31.4 com.google.protobuf:protobuf-java-util:3.15.2 com.google.protobuf:protobuf-java:3.15.2 com.google.re2j:re2j:1.6 -com.google.template:soy:2018-03-14 +com.google.template:soy:2021-02-01 com.googlecode.charts4j:charts4j:1.3 com.googlecode.json-simple:json-simple:1.1.1 com.ibm.icu:icu4j:68.2 diff --git a/core/gradle/dependency-locks/runtimeClasspath.lockfile b/core/gradle/dependency-locks/runtimeClasspath.lockfile index 9e3ec7b3c..d67debded 100644 --- a/core/gradle/dependency-locks/runtimeClasspath.lockfile +++ b/core/gradle/dependency-locks/runtimeClasspath.lockfile @@ -110,9 +110,10 @@ com.google.cloud:google-cloud-secretmanager:1.4.0 com.google.cloud:google-cloud-spanner:2.0.2 com.google.code.findbugs:jsr305:3.0.2 com.google.code.gson:gson:2.8.6 -com.google.common.html.types:types:1.0.4 +com.google.common.html.types:types:1.0.6 com.google.dagger:dagger:2.33 com.google.errorprone:error_prone_annotations:2.5.1 +com.google.escapevelocity:escapevelocity:0.9.1 com.google.flogger:flogger-system-backend:0.5.1 com.google.flogger:flogger:0.5.1 com.google.flogger:google-extensions:0.5.1 @@ -140,7 +141,7 @@ com.google.oauth-client:google-oauth-client:1.31.4 com.google.protobuf:protobuf-java-util:3.15.2 com.google.protobuf:protobuf-java:3.15.2 com.google.re2j:re2j:1.6 -com.google.template:soy:2018-03-14 +com.google.template:soy:2021-02-01 com.googlecode.charts4j:charts4j:1.3 com.googlecode.json-simple:json-simple:1.1.1 com.ibm.icu:icu4j:68.2 diff --git a/core/gradle/dependency-locks/soy.lockfile b/core/gradle/dependency-locks/soy.lockfile index 4706c74ae..6da9c5ff3 100644 --- a/core/gradle/dependency-locks/soy.lockfile +++ b/core/gradle/dependency-locks/soy.lockfile @@ -5,25 +5,25 @@ aopalliance:aopalliance:1.0 args4j:args4j:2.0.23 com.google.code.findbugs:jsr305:3.0.2 com.google.code.gson:gson:2.7 -com.google.common.html.types:types:1.0.4 +com.google.common.html.types:types:1.0.6 com.google.errorprone:error_prone_annotations:2.3.4 +com.google.escapevelocity:escapevelocity:0.9.1 com.google.guava:failureaccess:1.0.1 com.google.guava:guava:30.1-jre com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava -com.google.gwt:gwt-user:2.8.0-beta1 com.google.inject.extensions:guice-multibindings:4.1.0 com.google.inject:guice:5.0.1 com.google.j2objc:j2objc-annotations:1.3 +com.google.jsinterop:jsinterop-annotations:1.0.1 com.google.protobuf:protobuf-java:3.13.0 -com.google.template:soy:2018-03-14 +com.google.template:soy:2021-02-01 com.ibm.icu:icu4j:57.1 javax.annotation:jsr250-api:1.0 javax.inject:javax.inject:1 -javax.validation:validation-api:1.0.0.GA org.checkerframework:checker-qual:3.5.0 org.json:json:20160212 -org.ow2.asm:asm-analysis:6.0 -org.ow2.asm:asm-commons:6.0 -org.ow2.asm:asm-tree:6.0 -org.ow2.asm:asm-util:6.0 -org.ow2.asm:asm:6.0 +org.ow2.asm:asm-analysis:7.0 +org.ow2.asm:asm-commons:7.0 +org.ow2.asm:asm-tree:7.0 +org.ow2.asm:asm-util:7.0 +org.ow2.asm:asm:7.0 diff --git a/core/gradle/dependency-locks/testCompile.lockfile b/core/gradle/dependency-locks/testCompile.lockfile index cc889facc..8e64dd0b4 100644 --- a/core/gradle/dependency-locks/testCompile.lockfile +++ b/core/gradle/dependency-locks/testCompile.lockfile @@ -106,9 +106,10 @@ com.google.cloud:google-cloud-secretmanager:1.4.0 com.google.cloud:google-cloud-spanner:2.0.2 com.google.code.findbugs:jsr305:3.0.2 com.google.code.gson:gson:2.8.6 -com.google.common.html.types:types:1.0.4 +com.google.common.html.types:types:1.0.6 com.google.dagger:dagger:2.33 com.google.errorprone:error_prone_annotations:2.5.1 +com.google.escapevelocity:escapevelocity:0.9.1 com.google.flogger:flogger-system-backend:0.5.1 com.google.flogger:flogger:0.5.1 com.google.flogger:google-extensions:0.5.1 @@ -138,7 +139,7 @@ com.google.oauth-client:google-oauth-client:1.31.4 com.google.protobuf:protobuf-java-util:3.15.2 com.google.protobuf:protobuf-java:3.15.2 com.google.re2j:re2j:1.6 -com.google.template:soy:2018-03-14 +com.google.template:soy:2021-02-01 com.google.truth.extensions:truth-java8-extension:1.1.2 com.google.truth:truth:1.1.2 com.googlecode.charts4j:charts4j:1.3 diff --git a/core/gradle/dependency-locks/testCompileClasspath.lockfile b/core/gradle/dependency-locks/testCompileClasspath.lockfile index 9b3f9b8e4..d112fcc04 100644 --- a/core/gradle/dependency-locks/testCompileClasspath.lockfile +++ b/core/gradle/dependency-locks/testCompileClasspath.lockfile @@ -105,9 +105,10 @@ com.google.cloud:google-cloud-secretmanager:1.4.0 com.google.cloud:google-cloud-spanner:2.0.2 com.google.code.findbugs:jsr305:3.0.2 com.google.code.gson:gson:2.8.6 -com.google.common.html.types:types:1.0.4 +com.google.common.html.types:types:1.0.6 com.google.dagger:dagger:2.33 com.google.errorprone:error_prone_annotations:2.5.1 +com.google.escapevelocity:escapevelocity:0.9.1 com.google.flogger:flogger:0.5.1 com.google.flogger:google-extensions:0.5.1 com.google.guava:failureaccess:1.0.1 @@ -136,7 +137,7 @@ com.google.oauth-client:google-oauth-client:1.31.4 com.google.protobuf:protobuf-java-util:3.14.0 com.google.protobuf:protobuf-java:3.15.2 com.google.re2j:re2j:1.6 -com.google.template:soy:2018-03-14 +com.google.template:soy:2021-02-01 com.google.truth.extensions:truth-java8-extension:1.1.2 com.google.truth:truth:1.1.2 com.googlecode.charts4j:charts4j:1.3 diff --git a/core/gradle/dependency-locks/testRuntime.lockfile b/core/gradle/dependency-locks/testRuntime.lockfile index 4acfa9588..ca0377997 100644 --- a/core/gradle/dependency-locks/testRuntime.lockfile +++ b/core/gradle/dependency-locks/testRuntime.lockfile @@ -111,9 +111,10 @@ com.google.cloud:google-cloud-secretmanager:1.4.0 com.google.cloud:google-cloud-spanner:2.0.2 com.google.code.findbugs:jsr305:3.0.2 com.google.code.gson:gson:2.8.6 -com.google.common.html.types:types:1.0.4 +com.google.common.html.types:types:1.0.6 com.google.dagger:dagger:2.33 com.google.errorprone:error_prone_annotations:2.5.1 +com.google.escapevelocity:escapevelocity:0.9.1 com.google.flogger:flogger-system-backend:0.5.1 com.google.flogger:flogger:0.5.1 com.google.flogger:google-extensions:0.5.1 @@ -143,7 +144,7 @@ com.google.oauth-client:google-oauth-client:1.31.4 com.google.protobuf:protobuf-java-util:3.15.2 com.google.protobuf:protobuf-java:3.15.2 com.google.re2j:re2j:1.6 -com.google.template:soy:2018-03-14 +com.google.template:soy:2021-02-01 com.google.truth.extensions:truth-java8-extension:1.1.2 com.google.truth:truth:1.1.2 com.googlecode.charts4j:charts4j:1.3 diff --git a/core/gradle/dependency-locks/testRuntimeClasspath.lockfile b/core/gradle/dependency-locks/testRuntimeClasspath.lockfile index 491226a48..e78acec00 100644 --- a/core/gradle/dependency-locks/testRuntimeClasspath.lockfile +++ b/core/gradle/dependency-locks/testRuntimeClasspath.lockfile @@ -111,9 +111,10 @@ com.google.cloud:google-cloud-secretmanager:1.4.0 com.google.cloud:google-cloud-spanner:2.0.2 com.google.code.findbugs:jsr305:3.0.2 com.google.code.gson:gson:2.8.6 -com.google.common.html.types:types:1.0.4 +com.google.common.html.types:types:1.0.6 com.google.dagger:dagger:2.33 com.google.errorprone:error_prone_annotations:2.5.1 +com.google.escapevelocity:escapevelocity:0.9.1 com.google.flogger:flogger-system-backend:0.5.1 com.google.flogger:flogger:0.5.1 com.google.flogger:google-extensions:0.5.1 @@ -143,7 +144,7 @@ com.google.oauth-client:google-oauth-client:1.31.4 com.google.protobuf:protobuf-java-util:3.15.2 com.google.protobuf:protobuf-java:3.15.2 com.google.re2j:re2j:1.6 -com.google.template:soy:2018-03-14 +com.google.template:soy:2021-02-01 com.google.truth.extensions:truth-java8-extension:1.1.2 com.google.truth:truth:1.1.2 com.googlecode.charts4j:charts4j:1.3 diff --git a/core/karma.conf.js b/core/karma.conf.js deleted file mode 100644 index 90b5f47cf..000000000 --- a/core/karma.conf.js +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright 2019 The Nomulus Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -process.env.CHROME_BIN = require('puppeteer').executablePath() - -module.exports = function(config) { - config.set({ - basePath: '..', - browsers: ['ChromeHeadlessNoSandbox'], - customLaunchers: { - ChromeHeadlessNoSandbox: { - base: 'ChromeHeadless', - flags: ['--no-sandbox'] - } - }, - frameworks: ['jasmine', 'closure'], - singleRun: true, - autoWatch: false, - files: [ - 'node_modules/google-closure-library/closure/goog/base.js', - 'core/src/test/javascript/**/*_test.js', - { - pattern: 'core/src/test/javascript/**/!(*_test).js', - included: false - }, - { - pattern: 'core/src/main/javascript/**/*.js', - included: false - }, - { - pattern: 'core/build/generated/sources/custom/java/main/**/*.soy.js', - included: false - }, - { - pattern: 'node_modules/google-closure-library/closure/goog/deps.js', - included: false, - served: false - }, - { - pattern: 'node_modules/google-closure-library/closure/goog/**/*.js', - included: false - }, - { - pattern: 'core/build/resources/main/google/registry/ui/assets/images/*.png', - included: false - }, - { - pattern: 'core/build/resources/main/google/registry/ui/assets/images/icons/svg/*.svg', - included: false - } - ], - preprocessors: { - 'node_modules/google-closure-library/closure/goog/deps.js': ['closure', 'closure-deps'], - 'node_modules/google-closure-library/closure/goog/base.js': ['closure'], - 'node_modules/google-closure-library/closure/**/*.js': ['closure'], - 'core/src/*/javascript/**/*.js': ['closure'], - 'core/build/generated/sources/custom/java/main/**/*.soy.js': ['closure'], - }, - proxies: { - "/assets/": "/base/core/build/resources/main/google/registry/ui/assets/" - } - }); -}; - diff --git a/core/src/main/java/google/registry/config/RegistryConfig.java b/core/src/main/java/google/registry/config/RegistryConfig.java index 46ad5b77f..55ebdd954 100644 --- a/core/src/main/java/google/registry/config/RegistryConfig.java +++ b/core/src/main/java/google/registry/config/RegistryConfig.java @@ -203,7 +203,7 @@ public final class RegistryConfig { * Configuration for analytics services installed in the web console. * * @see google.registry.ui.server.registrar.ConsoleUiAction - * @see google.registry.ui.soy.AnalyticsSoyInfo + * @see google.registry.ui.soy.registrar.AnalyticsSoyInfo */ @Provides @Config("analyticsConfig") diff --git a/core/src/main/java/google/registry/ui/server/registrar/ConsoleOteSetupAction.java b/core/src/main/java/google/registry/ui/server/registrar/ConsoleOteSetupAction.java index 6510e1e98..86204b029 100644 --- a/core/src/main/java/google/registry/ui/server/registrar/ConsoleOteSetupAction.java +++ b/core/src/main/java/google/registry/ui/server/registrar/ConsoleOteSetupAction.java @@ -61,9 +61,10 @@ public final class ConsoleOteSetupAction extends HtmlAction { private static final FluentLogger logger = FluentLogger.forEnclosingClass(); private static final Supplier TOFU_SUPPLIER = SoyTemplateUtils.createTofuSupplier( - google.registry.ui.soy.ConsoleSoyInfo.getInstance(), - google.registry.ui.soy.FormsSoyInfo.getInstance(), - google.registry.ui.soy.AnalyticsSoyInfo.getInstance(), + google.registry.ui.soy.registrar.AnalyticsSoyInfo.getInstance(), + google.registry.ui.soy.registrar.ConsoleSoyInfo.getInstance(), + google.registry.ui.soy.registrar.ConsoleUtilsSoyInfo.getInstance(), + google.registry.ui.soy.registrar.FormsSoyInfo.getInstance(), google.registry.ui.soy.registrar.OteSetupConsoleSoyInfo.getInstance()); @Inject AuthenticatedRegistrarAccessor registrarAccessor; diff --git a/core/src/main/java/google/registry/ui/server/registrar/ConsoleRegistrarCreatorAction.java b/core/src/main/java/google/registry/ui/server/registrar/ConsoleRegistrarCreatorAction.java index e75d5a8d9..04f94b281 100644 --- a/core/src/main/java/google/registry/ui/server/registrar/ConsoleRegistrarCreatorAction.java +++ b/core/src/main/java/google/registry/ui/server/registrar/ConsoleRegistrarCreatorAction.java @@ -74,9 +74,10 @@ public final class ConsoleRegistrarCreatorAction extends HtmlAction { private static final Supplier TOFU_SUPPLIER = SoyTemplateUtils.createTofuSupplier( - google.registry.ui.soy.ConsoleSoyInfo.getInstance(), - google.registry.ui.soy.FormsSoyInfo.getInstance(), - google.registry.ui.soy.AnalyticsSoyInfo.getInstance(), + google.registry.ui.soy.registrar.AnalyticsSoyInfo.getInstance(), + google.registry.ui.soy.registrar.ConsoleSoyInfo.getInstance(), + google.registry.ui.soy.registrar.ConsoleUtilsSoyInfo.getInstance(), + google.registry.ui.soy.registrar.FormsSoyInfo.getInstance(), google.registry.ui.soy.registrar.RegistrarCreateConsoleSoyInfo.getInstance()); @Inject AuthenticatedRegistrarAccessor registrarAccessor; diff --git a/core/src/main/java/google/registry/ui/server/registrar/ConsoleUiAction.java b/core/src/main/java/google/registry/ui/server/registrar/ConsoleUiAction.java index 688573507..e27c5bc02 100644 --- a/core/src/main/java/google/registry/ui/server/registrar/ConsoleUiAction.java +++ b/core/src/main/java/google/registry/ui/server/registrar/ConsoleUiAction.java @@ -50,9 +50,9 @@ public final class ConsoleUiAction extends HtmlAction { private static final Supplier TOFU_SUPPLIER = SoyTemplateUtils.createTofuSupplier( - google.registry.ui.soy.ConsoleSoyInfo.getInstance(), + google.registry.ui.soy.registrar.AnalyticsSoyInfo.getInstance(), google.registry.ui.soy.registrar.ConsoleSoyInfo.getInstance(), - google.registry.ui.soy.AnalyticsSoyInfo.getInstance()); + google.registry.ui.soy.registrar.ConsoleUtilsSoyInfo.getInstance()); @Inject RegistrarConsoleMetrics registrarConsoleMetrics; @Inject AuthenticatedRegistrarAccessor registrarAccessor; diff --git a/core/src/main/java/google/registry/ui/server/registrar/RegistryLockVerifyAction.java b/core/src/main/java/google/registry/ui/server/registrar/RegistryLockVerifyAction.java index 98b64a413..09fb1b194 100644 --- a/core/src/main/java/google/registry/ui/server/registrar/RegistryLockVerifyAction.java +++ b/core/src/main/java/google/registry/ui/server/registrar/RegistryLockVerifyAction.java @@ -43,8 +43,9 @@ public final class RegistryLockVerifyAction extends HtmlAction { private static final Supplier TOFU_SUPPLIER = SoyTemplateUtils.createTofuSupplier( - google.registry.ui.soy.ConsoleSoyInfo.getInstance(), - google.registry.ui.soy.AnalyticsSoyInfo.getInstance(), + google.registry.ui.soy.registrar.AnalyticsSoyInfo.getInstance(), + google.registry.ui.soy.registrar.ConsoleSoyInfo.getInstance(), + google.registry.ui.soy.registrar.ConsoleUtilsSoyInfo.getInstance(), google.registry.ui.soy.registrar.RegistryLockVerificationSoyInfo.getInstance()); private final DomainLockUtils domainLockUtils; diff --git a/core/src/main/javascript/checks.js b/core/src/main/javascript/checks.js new file mode 100644 index 000000000..dadd95c2d --- /dev/null +++ b/core/src/main/javascript/checks.js @@ -0,0 +1,94 @@ +/** + * @fileoverview Provides Soy runtime checks for safe types. + * + * NOTE (gbrodman) this file is taken from the open source version located at + * https://github.com/google/closure-templates/blob/6c8cf1c7916abd0ab5d7e9d259985873f8af4fd2/javascript/checks.js + */ + +goog.provide('soy.checks'); + +goog.require('goog.asserts'); +goog.require('goog.soy.data.SanitizedContentKind'); +goog.require('goog.soy.data.SanitizedCss'); +goog.require('goog.soy.data.SanitizedHtml'); +goog.require('goog.soy.data.SanitizedHtmlAttribute'); +goog.require('goog.soy.data.SanitizedJs'); +goog.require('goog.soy.data.SanitizedTrustedResourceUri'); +goog.require('goog.soy.data.SanitizedUri'); + +/** + * Checks whether a given value is of a given content kind. + * + * @param {?} value The value to be examined. + * @param {!goog.soy.data.SanitizedContentKind} contentKind The desired content + * kind. + * @param {!Object} constructor + * @return {boolean} Whether the given value is of the given kind. + * @private + */ +soy.checks.isContentKind_ = function(value, contentKind, constructor) { + var ret = value != null && value.contentKind === contentKind; + if (ret) { + goog.asserts.assert(value.constructor === constructor); + } + return ret; +}; + +/** + * @param {?} value + * @return {boolean} + */ +soy.checks.isHtml = function(value) { + return soy.checks.isContentKind_( + value, goog.soy.data.SanitizedContentKind.HTML, + goog.soy.data.SanitizedHtml); +}; + +/** + * @param {?} value + * @return {boolean} + */ +soy.checks.isCss = function(value) { + return soy.checks.isContentKind_( + value, goog.soy.data.SanitizedContentKind.CSS, + goog.soy.data.SanitizedCss); +}; + +/** + * @param {?} value + * @return {boolean} + */ +soy.checks.isAttribute = function(value) { + return soy.checks.isContentKind_( + value, goog.soy.data.SanitizedContentKind.ATTRIBUTES, + goog.soy.data.SanitizedHtmlAttribute); +}; + +/** + * @param {?} value + * @return {boolean} + */ +soy.checks.isJS = function(value) { + return soy.checks.isContentKind_( + value, goog.soy.data.SanitizedContentKind.JS, goog.soy.data.SanitizedJs); +}; + +/** + * @param {?} value + * @return {boolean} + */ +soy.checks.isTrustedResourceURI = function(value) { + return soy.checks.isContentKind_( + value, goog.soy.data.SanitizedContentKind.TRUSTED_RESOURCE_URI, + goog.soy.data.SanitizedTrustedResourceUri); +}; + +/** + * @param {?} value + * @return {boolean} + */ +soy.checks.isURI = function(value) { + return soy.checks.isContentKind_( + value, goog.soy.data.SanitizedContentKind.URI, + goog.soy.data.SanitizedUri); +}; diff --git a/core/src/main/javascript/google/registry/ui/js/forms.js b/core/src/main/javascript/google/registry/ui/js/forms.js index f852c0e09..bf770ff7a 100644 --- a/core/src/main/javascript/google/registry/ui/js/forms.js +++ b/core/src/main/javascript/google/registry/ui/js/forms.js @@ -33,7 +33,7 @@ goog.forwardDeclare('goog.events.KeyEvent'); */ registry.forms.focus = function(field) { field = goog.dom.getElement(field); - if (!goog.isNull(field) && goog.dom.isFocusable(field)) { + if (field !== null && goog.dom.isFocusable(field)) { goog.dom.forms.focusAndSelect(field); } }; @@ -45,7 +45,7 @@ registry.forms.focus = function(field) { * @param {string=} opt_field Erroneous field name. */ registry.forms.displayError = function(message, opt_field) { - if (!goog.isDef(opt_field)) { + if (opt_field === undefined) { registry.util.butter(message); return; } @@ -53,7 +53,7 @@ registry.forms.displayError = function(message, opt_field) { goog.dom.getElement(opt_field + '[0]'); // XXX: Transitioning to use of form.eltId instead of DOM id. If DOM id // lookup fails, then search forms for the named field. - if (goog.isDefAndNotNull(opt_field) && goog.isNull(input)) { + if (opt_field != null && input === null) { for (var fNdx in document.forms) { var form = document.forms[fNdx]; if (form[opt_field]) { @@ -62,7 +62,7 @@ registry.forms.displayError = function(message, opt_field) { } } } - if (!goog.isNull(input)) { + if (input !== null) { goog.dom.classlist.add(input, goog.getCssName('kd-formerror')); goog.dom.insertSiblingAfter( goog.dom.createDom(goog.dom.TagName.DIV, diff --git a/core/src/main/javascript/google/registry/ui/js/registrar/console.js b/core/src/main/javascript/google/registry/ui/js/registrar/console.js index d02cd884d..70c878e66 100644 --- a/core/src/main/javascript/google/registry/ui/js/registrar/console.js +++ b/core/src/main/javascript/google/registry/ui/js/registrar/console.js @@ -162,7 +162,7 @@ registry.registrar.Console.prototype.changeNavStyle = function() { var regNavlist = goog.dom.getRequiredElement('reg-navlist'); var path = hashToken.substring(0, slashNdx); var active = regNavlist.querySelector('a[href="#' + path + '"]'); - if (goog.isNull(active)) { + if (active === null) { registry.util.log('Unknown path or path form in changeNavStyle.'); return; } diff --git a/core/src/main/javascript/google/registry/ui/js/registrar/contact_settings.js b/core/src/main/javascript/google/registry/ui/js/registrar/contact_settings.js index 81e602582..d3311cd4e 100644 --- a/core/src/main/javascript/google/registry/ui/js/registrar/contact_settings.js +++ b/core/src/main/javascript/google/registry/ui/js/registrar/contact_settings.js @@ -54,7 +54,7 @@ goog.inherits(registry.registrar.ContactSettings, registry.ResourceComponent); registry.registrar.ContactSettings.prototype.setupAppbar = function() { registry.registrar.ContactSettings.base(this, 'setupAppbar'); // Setup delete only on existing items, not on creates. - if (goog.isDefAndNotNull(this.model)) { + if (this.model != null) { var deleteBtn = goog.dom.createDom( goog.dom.TagName.BUTTON, { type: 'button', @@ -159,7 +159,7 @@ registry.registrar.ContactSettings.prototype.sendDelete = function() { ndxToDel = i; } } - if (goog.isNull(ndxToDel)) { + if (ndxToDel === null) { throw new Error('Email to delete does not match model.'); } var modelCopy = /** @type {!Object} diff --git a/core/src/main/javascript/google/registry/ui/js/util.js b/core/src/main/javascript/google/registry/ui/js/util.js index 119027f8c..99838b1c5 100644 --- a/core/src/main/javascript/google/registry/ui/js/util.js +++ b/core/src/main/javascript/google/registry/ui/js/util.js @@ -25,8 +25,7 @@ goog.require('goog.soy'); */ registry.util.log = function(var_args) { if (goog.DEBUG) { - if (goog.isDef(goog.global.console) && - goog.isDef(goog.global.console['log'])) { + if (goog.global.console !== undefined && goog.global.console['log'] !== undefined) { goog.global.console.log.apply(goog.global.console, arguments); } } diff --git a/core/src/main/javascript/soyutils_usegoog.js b/core/src/main/javascript/soyutils_usegoog.js index 544836487..d4eb9ef5e 100644 --- a/core/src/main/javascript/soyutils_usegoog.js +++ b/core/src/main/javascript/soyutils_usegoog.js @@ -18,7 +18,7 @@ * @fileoverview * * NOTE (gbrodman) this file is taken from the open source version located at - * https://github.com/google/closure-templates/blob/63f34802b543dadb72a078b006a0e7e4dbc71d7e/javascript/soyutils_usegoog.js + * https://github.com/google/closure-templates/blob/6c8cf1c7916abd0ab5d7e9d259985873f8af4fd2/javascript/soyutils_usegoog.js * and slightly modified so that it compiles. * * Utility functions and classes for Soy gencode @@ -62,20 +62,26 @@ goog.require('goog.soy.data.SanitizedHtmlAttribute'); goog.require('goog.soy.data.SanitizedJs'); goog.require('goog.soy.data.SanitizedTrustedResourceUri'); goog.require('goog.soy.data.SanitizedUri'); -goog.require('goog.soy.data.UnsanitizedText'); goog.require('goog.string'); goog.require('goog.string.Const'); +goog.require('soy.checks'); +goog.requireType('goog.soy'); + // ----------------------------------------------------------------------------- -// soydata: Defines typed strings, e.g. an HTML string {@code "ac"} is -// semantically distinct from the plain text string {@code "ac"} and smart +// soydata: Defines typed strings, e.g. an HTML string `"ac"` is +// semantically distinct from the plain text string `"ac"` and smart // templates can take that distinction into account. + +/** @typedef {!goog.soy.data.SanitizedContent|{isInvokableFn: boolean}} */ +soydata.IdomFunction; + /** * Checks whether a given value is of a given content kind. * - * @param {*} value The value to be examined. - * @param {goog.soy.data.SanitizedContentKind} contentKind The desired content + * @param {?} value The value to be examined. + * @param {!goog.soy.data.SanitizedContentKind} contentKind The desired content * kind. * @return {boolean} Whether the given value is of the given kind. * @private @@ -89,14 +95,13 @@ soydata.isContentKind_ = function(value, contentKind) { return value != null && value.contentKind === contentKind; }; - /** * Returns a given value's contentDir property, constrained to a * goog.i18n.bidi.Dir value or null. Returns null if the value is null, * undefined, a primitive or does not have a contentDir property, or the * property's value is not 1 (for LTR), -1 (for RTL), or 0 (for neutral). * - * @param {*} value The value whose contentDir property, if any, is to + * @param {?} value The value whose contentDir property, if any, is to * be returned. * @return {?goog.i18n.bidi.Dir} The contentDir property. */ @@ -114,7 +119,6 @@ soydata.getContentDir = function(value) { return null; }; - /** * This class is only a holder for `soydata.SanitizedHtml.from`. Do not * instantiate or extend it. Use `goog.soy.data.SanitizedHtml` instead. @@ -134,7 +138,7 @@ goog.inherits(soydata.SanitizedHtml, goog.soy.data.SanitizedHtml); * * This HTML-escapes the value unless it is already SanitizedHtml or SafeHtml. * - * @param {*} value The value to convert. If it is already a SanitizedHtml + * @param {?} value The value to convert. If it is already a SanitizedHtml * object, it is left alone. * @return {!goog.soy.data.SanitizedHtml} A SanitizedHtml object derived from * the stringified value. It is escaped unless the input is SanitizedHtml or @@ -142,9 +146,7 @@ goog.inherits(soydata.SanitizedHtml, goog.soy.data.SanitizedHtml); */ soydata.SanitizedHtml.from = function(value) { // The check is soydata.isContentKind_() inlined for performance. - if (value != null && - value.contentKind === goog.soy.data.SanitizedContentKind.HTML) { - goog.asserts.assert(value.constructor === goog.soy.data.SanitizedHtml); + if (soy.checks.isHtml(value)) { return /** @type {!goog.soy.data.SanitizedHtml} */ (value); } if (value instanceof goog.html.SafeHtml) { @@ -162,7 +164,7 @@ soydata.SanitizedHtml.from = function(value) { * @private */ soydata.$$EMPTY_STRING_ = { - VALUE: '' + VALUE: '', }; @@ -176,7 +178,7 @@ soydata.$$EMPTY_STRING_ = { * is not always safe and calls for careful review. * * @param {function(new: T)} ctor A constructor. - * @return {!function(*, ?goog.i18n.bidi.Dir=): T} A factory that takes + * @return {function(*, ?goog.i18n.bidi.Dir=): T} A factory that takes * content and an optional content direction and returns a new instance. If * the content direction is undefined, ctor.prototype.contentDir is used. * @template T @@ -196,7 +198,7 @@ soydata.$$makeSanitizedContentFactory_ = function(ctor) { /** * Creates a ctor-type SanitizedContent instance. * - * @param {*} content The content to put in the instance. + * @param {?} content The content to put in the instance. * @param {?goog.i18n.bidi.Dir=} opt_contentDir The content direction. If * undefined, ctor.prototype.contentDir is used. * @return {!goog.soy.data.SanitizedContent} The new instance. It is actually @@ -225,7 +227,7 @@ soydata.$$makeSanitizedContentFactory_ = function(ctor) { * is not always safe and calls for careful review. * * @param {function(new: T, string)} ctor A constructor. - * @return {!function(*): T} A factory that takes content and returns a new + * @return {function(*): T} A factory that takes content and returns a new * instance (with default directionality, i.e. ctor.prototype.contentDir). * @template T * @private @@ -244,7 +246,7 @@ soydata.$$makeSanitizedContentFactoryWithDefaultDirOnly_ = function(ctor) { /** * Creates a ctor-type SanitizedContent instance. * - * @param {*} content The content to put in the instance. + * @param {?} content The content to put in the instance. * @return {!goog.soy.data.SanitizedContent} The new instance. It is actually * of type T above (ctor's type, a descendant of SanitizedContent), but * there is no way to express that here. @@ -258,34 +260,15 @@ soydata.$$makeSanitizedContentFactoryWithDefaultDirOnly_ = function(ctor) { // ----------------------------------------------------------------------------- -// Sanitized content ordainers. Please use these with extreme caution (with the -// exception of markUnsanitizedText). A good recommendation is to limit usage -// of these to just a handful of files in your source tree where usages can be -// carefully audited. - - -/** - * Protects a string from being used in an noAutoescaped context. - * - * This is useful for content where there is significant risk of accidental - * unescaped usage in a Soy template. A great case is for user-controlled - * data that has historically been a source of vulernabilities. - * - * @param {*} content Text to protect. - * @param {?goog.i18n.bidi.Dir=} opt_contentDir The content direction; null if - * unknown and thus to be estimated when necessary. Default: null. - * @return {!goog.soy.data.UnsanitizedText} A wrapper that is rejected by the - * Soy noAutoescape print directive. - */ -soydata.markUnsanitizedText = function(content, opt_contentDir) { - return new goog.soy.data.UnsanitizedText(content, opt_contentDir); -}; +// Sanitized content ordainers. Please use these with extreme caution. A good +// recommendation is to limit usage of these to just a handful of files in your +// source tree where usages can be carefully audited. /** * Takes a leap of faith that the provided content is "safe" HTML. * - * @param {*} content A string of HTML that can safely be embedded in + * @param {?} content A string of HTML that can safely be embedded in * a PCDATA context in your app. If you would be surprised to find that an * HTML sanitizer produced `s` (e.g. it runs code or fetches bad URLs) * and you wouldn't write a template that produces `s` on security or @@ -303,7 +286,7 @@ soydata.VERY_UNSAFE.ordainSanitizedHtml = * Takes a leap of faith that the provided content is "safe" (non-attacker- * controlled, XSS-free) Javascript. * - * @param {*} content Javascript source that when evaluated does not + * @param {?} content Javascript source that when evaluated does not * execute any attacker-controlled scripts. * @return {!goog.soy.data.SanitizedJs} Sanitized content wrapper that indicates * to Soy not to escape when printed as Javascript source. @@ -322,7 +305,7 @@ soydata.VERY_UNSAFE.ordainSanitizedJs = * attribute), such as if it's already been encoded or if it's a Javascript: * URI. * - * @param {*} content A chunk of URI that the caller knows is safe to + * @param {?} content A chunk of URI that the caller knows is safe to * emit in a template. * @return {!goog.soy.data.SanitizedUri} Sanitized content wrapper that * indicates to Soy not to escape or filter when printed in URI context. @@ -339,7 +322,7 @@ soydata.VERY_UNSAFE.ordainSanitizedUri = * This creates a Soy SanitizedContent object which indicates to Soy there is * no need to filter it when printed as a TrustedResourceUri. * - * @param {*} content A chunk of TrustedResourceUri such as that the caller + * @param {?} content A chunk of TrustedResourceUri such as that the caller * knows is safe to emit in a template. * @return {!goog.soy.data.SanitizedTrustedResourceUri} Sanitized content * wrapper that indicates to Soy not to escape or filter when printed in @@ -354,8 +337,8 @@ soydata.VERY_UNSAFE.ordainSanitizedTrustedResourceUri = * Takes a leap of faith that the provided content is "safe" to use as an * HTML attribute. * - * @param {*} content An attribute name and value, such as - * {@code dir="ltr"}. + * @param {?} content An attribute name and value, such as + * `dir="ltr"`. * @return {!goog.soy.data.SanitizedHtmlAttribute} Sanitized content wrapper * that indicates to Soy not to escape when printed as an HTML attribute. */ @@ -368,7 +351,7 @@ soydata.VERY_UNSAFE.ordainSanitizedHtmlAttribute = * Takes a leap of faith that the provided content is "safe" to use as CSS * in a style block. * - * @param {*} content CSS, such as `color:#c3d9ff`. + * @param {?} content CSS, such as `color:#c3d9ff`. * @return {!goog.soy.data.SanitizedCss} Sanitized CSS wrapper that indicates to * Soy there is no need to escape or filter when printed in CSS context. */ @@ -376,12 +359,47 @@ soydata.VERY_UNSAFE.ordainSanitizedCss = soydata.$$makeSanitizedContentFactoryWithDefaultDirOnly_( goog.soy.data.SanitizedCss); +// Utilities related to defining and stubbing soy templates + + +/** + * A map that allows us to dynamically replace templates. + * + * The key is the fully qualified template name and the value is a replacement + * to call instead. + * + * @type {?Object} + * @const + * @public + */ +soy.$$stubsMap = goog.DEBUG ? {} : null; + // ----------------------------------------------------------------------------- // Soy-generated utilities in the soy namespace. Contains implementations for // common soyfunctions (e.g. keys()) and escaping/print directives. +/** + * Provides a compact serialization format for the key structure. + * @param {?} item + * @return {string} + */ +soy.$$serializeKey = function(item) { + const stringified = String(item); + let delimiter; + if (item == null) { + delimiter = '_'; + } else if (typeof item === 'number') { + delimiter = '#'; + } else { + delimiter = ':'; + } + return `${stringified.length}${delimiter}${stringified}`; +}; + + + /** * Whether the locale is right-to-left. * @@ -390,29 +408,14 @@ soydata.VERY_UNSAFE.ordainSanitizedCss = soy.$$IS_LOCALE_RTL = goog.i18n.bidi.IS_RTL; -/** - * Builds an augmented map. The returned map will contain mappings from both - * the base map and the additional map. If the same key appears in both, then - * the value from the additional map will be visible, while the value from the - * base map will be hidden. The base map will be used, but not modified. - * - * @param {!Object} baseMap The original map to augment. - * @param {!Object} additionalMap A map containing the additional mappings. - * @return {!Object} An augmented map containing both the original and - * additional mappings. - */ -soy.$$augmentMap = function(baseMap, additionalMap) { - return soy.$$assignDefaults(soy.$$assignDefaults({}, additionalMap), baseMap); -}; - /** * Copies extra properties into an object if they do not already exist. The * destination object is mutated in the process. * - * @param {!Object} obj The destination object to update. - * @param {!Object} defaults An object with default properties to apply. - * @return {!Object} The destination object for convenience. + * @param {?} obj The destination object to update. + * @param {?} defaults An object with default properties to apply. + * @return {?} The destination object for convenience. */ soy.$$assignDefaults = function(obj, defaults) { for (var key in defaults) { @@ -425,27 +428,9 @@ soy.$$assignDefaults = function(obj, defaults) { }; -/** - * Checks that the given map key is a string. - * - *

This is used to validate keys for legacy object map literals. - * - * @param {*} key Key to check. - * @return {string} The given key. - */ -soy.$$checkLegacyObjectMapLiteralKey = function(key) { - if ((typeof key) != 'string') { - throw Error( - 'Map literal\'s key expression must evaluate to string' + - ' (encountered type "' + (typeof key) + '").'); - } - return key; -}; - - /** * Gets the keys in a map as an array. There are no guarantees on the order. - * @param {Object} map The map to get the keys of. + * @param {!Object} map The map to get the keys of. * @return {!Array} The array of keys in the given map. */ soy.$$getMapKeys = function(map) { @@ -475,19 +460,66 @@ soy.$$checkNotNull = function(val) { /** * Parses the given string into a base 10 integer. Returns null if parse is * unsuccessful. - * @param {string} str The string to parse + * @param {?string} str The string to parse * @return {?number} The string parsed as a base 10 integer, or null if * unsuccessful */ soy.$$parseInt = function(str) { - var parsed = parseInt(str, 10); + var parsed = parseInt(String(str), 10); return isNaN(parsed) ? null : parsed; }; +/** + * When equals comparison cannot be expressed using JS runtime semantics for ==, + * bail out to a runtime function. In practice, this only means comparisons + * of boolean, string and number are valid for equals, and everything else needs + * this function. Some sanitized content may be functions or objects that need + * to be coerced to a string. + * @param {?} valueOne + * @param {?} valueTwo + * @return {boolean} + */ +soy.$$equals = function(valueOne, valueTwo) { + // Incremental DOM functions have to be coerced to a string. At runtime + // they are tagged with a type for ATTR or HTML. They both need to be + // the same to be considered structurally equal. Beware, as this is a + // very expensive function. + if ((valueOne && valueTwo) && + (valueOne.isInvokableFn && valueTwo.isInvokableFn)) { + if ((/** @type {?} */ (valueOne)).contentKind !== + (/** @type {?} */ (valueTwo)).contentKind) { + return false; + } else { + return valueOne.toString() === valueTwo.toString(); + } + } + + // Likewise for sanitized content. + if (valueOne instanceof goog.soy.data.SanitizedContent && + valueTwo instanceof goog.soy.data.SanitizedContent) { + if (valueOne.contentKind != valueTwo.contentKind) { + return false; + } else { + return valueOne.toString() == valueTwo.toString(); + } + } + + // Rely on javascript semantics for comparing two objects. + return valueOne == valueTwo; +}; + + +/** + * @param {?} value + * @return {boolean} + */ +soy.$$isFunction = function(value) { + return typeof value === 'function'; +}; /** * Parses the given string into a float. Returns null if parse is unsuccessful. - * @param {string} str The string to parse + * @param {?string} str The string to parse * @return {?number} The string parsed as a float, or null if unsuccessful. */ soy.$$parseFloat = function(str) { @@ -495,6 +527,50 @@ soy.$$parseFloat = function(str) { return isNaN(parsed) ? null : parsed; }; +/** + * Returns a random integer. + * @return {number} a random integer between 0 and num + */ +soy.$$randomInt = function(/** number */ num) { + return Math.floor(Math.random() * num); +}; + +/** + * Rounds the given value to the closest decimal point left (negative numbers) + * or right (positive numbers) of the decimal point + * + * TODO(b/112835292): This is probably not something that anyone should use, + * instead they should use an i18n friendly number formatting routine. + * + * @return {number} the rounded value + */ +soy.$$round = function(/** number */ num, /** number */ numDigitsAfterPt) { + const shift = Math.pow(10, numDigitsAfterPt); + return Math.round(num * shift) / shift; +}; + +/** @return {boolean} returns whether the needle was found in the haystack */ +soy.$$strContains = function(/** string */ haystack, /** string */ needle) { + return haystack.indexOf(needle) != -1; +}; + +/** + * Coerce the given value into a bool. + * + * For objects of type `SanitizedContent`, the contents are used to determine + * the boolean value; this is because the outer `SanitizedContent` object + * instance is always truthy (unless it's null). + * + * @param {*} arg The argument to coerce. + * @return {boolean} + */ +soy.$$coerceToBoolean = function(arg) { + if (arg instanceof goog.soy.data.SanitizedContent) { + return !!arg.getContent(); + } + return !!arg; +}; + /** * Gets a consistent unique id for the given delegate template name. Two calls @@ -522,14 +598,14 @@ soy.$$getDelTemplateId = function(delTemplateName) { /** * Map from registered delegate template key to the priority of the * implementation. - * @type {Object} + * @const {!Object} * @private */ soy.$$DELEGATE_REGISTRY_PRIORITIES_ = {}; /** * Map from registered delegate template key to the implementation function. - * @type {Object} + * @const {!Object} * @private */ soy.$$DELEGATE_REGISTRY_FUNCTIONS_ = {}; @@ -545,10 +621,11 @@ soy.$$DELEGATE_REGISTRY_FUNCTIONS_ = {}; * @param {string} delTemplateVariant The delegate template variant (can be * empty string). * @param {number} delPriority The implementation's priority value. - * @param {Function} delFn The implementation function. + * @param {!Function} delFn The implementation function. */ soy.$$registerDelegateFn = function( delTemplateId, delTemplateVariant, delPriority, delFn) { + var mapKey = 'key_' + delTemplateId + ':' + delTemplateVariant; var currPriority = soy.$$DELEGATE_REGISTRY_PRIORITIES_[mapKey]; if (currPriority === undefined || delPriority > currPriority) { @@ -559,7 +636,7 @@ soy.$$registerDelegateFn = function( // Registering same-priority function: error. throw Error( 'Encountered two active delegates with the same priority ("' + - delTemplateId + ':' + delTemplateVariant + '").'); + delTemplateId + ':' + delTemplateVariant + '").'); } else { // Registering lower-priority function: do nothing. } @@ -579,13 +656,14 @@ soy.$$registerDelegateFn = function( * empty string). * @param {boolean} allowsEmptyDefault Whether to default to the empty template * function if there's no active implementation. - * @return {Function} The retrieved implementation function. + * @return {!Function} The retrieved implementation function. */ soy.$$getDelegateFn = function( delTemplateId, delTemplateVariant, allowsEmptyDefault) { - var delFn = - soy.$$DELEGATE_REGISTRY_FUNCTIONS_['key_' + delTemplateId + ':' + delTemplateVariant]; - if (!delFn && delTemplateVariant != '') { + + var delFn = soy.$$DELEGATE_REGISTRY_FUNCTIONS_[ + 'key_' + delTemplateId + ':' + delTemplateVariant]; + if (! delFn && delTemplateVariant != '') { // Fallback to empty variant. delFn = soy.$$DELEGATE_REGISTRY_FUNCTIONS_['key_' + delTemplateId + ':']; } @@ -607,14 +685,12 @@ soy.$$getDelegateFn = function( * Private helper soy.$$getDelegateFn(). This is the empty template function * that is returned whenever there's no delegate implementation found. * - * @param {Object=} opt_data - * @param {Object=} opt_ijData - * @param {Object=} opt_ijData_deprecated TODO(b/36644846): remove + * Note: This is also used for idom. + * * @return {string} * @private */ -soy.$$EMPTY_TEMPLATE_FN_ = function( - opt_data, opt_ijData, opt_ijData_deprecated) { +soy.$$EMPTY_TEMPLATE_FN_ = function() { return ''; }; @@ -635,7 +711,7 @@ soy.$$EMPTY_TEMPLATE_FN_ = function( * string as SanitizedContent, since it's a no-op for empty strings anyways. * * @param {function(new: T)} ctor A constructor. - * @return {!function(*, ?goog.i18n.bidi.Dir=): (T|soydata.$$EMPTY_STRING_)} + * @return {function(*, ?goog.i18n.bidi.Dir=): (T|!soydata.$$EMPTY_STRING_)} * A factory that takes content and an optional content direction and * returns a new instance, or an empty string. If the content direction is * undefined, ctor.prototype.contentDir is used. @@ -656,10 +732,10 @@ soydata.$$makeSanitizedContentFactoryForInternalBlocks_ = function(ctor) { /** * Creates a ctor-type SanitizedContent instance. * - * @param {*} content The content to put in the instance. + * @param {?} content The content to put in the instance. * @param {?goog.i18n.bidi.Dir=} opt_contentDir The content direction. If * undefined, ctor.prototype.contentDir is used. - * @return {!goog.soy.data.SanitizedContent|soydata.$$EMPTY_STRING_} The new + * @return {!goog.soy.data.SanitizedContent|!soydata.$$EMPTY_STRING_} The new * instance, or an empty string. A new instance is actually of type T * above (ctor's type, a descendant of SanitizedContent), but there's no * way to express that here. @@ -692,7 +768,7 @@ soydata.$$makeSanitizedContentFactoryForInternalBlocks_ = function(ctor) { * string as SanitizedContent, since it's a no-op for empty strings anyways. * * @param {function(new: T)} ctor A constructor. - * @return {!function(*): (T|soydata.$$EMPTY_STRING_)} A + * @return {function(*): (T|!soydata.$$EMPTY_STRING_)} A * factory that takes content and returns a * new instance (with default directionality, i.e. * ctor.prototype.contentDir), or an empty string. @@ -714,8 +790,8 @@ soydata.$$makeSanitizedContentFactoryWithDefaultDirOnlyForInternalBlocks_ = /** * Creates a ctor-type SanitizedContent instance. * - * @param {*} content The content to put in the instance. - * @return {!goog.soy.data.SanitizedContent|soydata.$$EMPTY_STRING_} The new + * @param {?} content The content to put in the instance. + * @return {!goog.soy.data.SanitizedContent|!soydata.$$EMPTY_STRING_} The new * instance, or an empty string. A new instance is actually of type T * above (ctor's type, a descendant of SanitizedContent), but there's no * way to express that here. @@ -732,32 +808,13 @@ soydata.$$makeSanitizedContentFactoryWithDefaultDirOnlyForInternalBlocks_ = }; -/** - * Creates kind="text" block contents (internal use only). - * - * @param {*} content Text. - * @param {?goog.i18n.bidi.Dir=} opt_contentDir The content direction; null if - * unknown and thus to be estimated when necessary. Default: null. - * @return {!goog.soy.data.UnsanitizedText|soydata.$$EMPTY_STRING_} Wrapped - * result. - */ -soydata.$$markUnsanitizedTextForInternalBlocks = function( - content, opt_contentDir) { - var contentString = String(content); - if (!contentString) { - return soydata.$$EMPTY_STRING_.VALUE; - } - return new goog.soy.data.UnsanitizedText(contentString, opt_contentDir); -}; - - /** * Creates kind="html" block contents (internal use only). * - * @param {*} content Text. + * @param {?} content Text. * @param {?goog.i18n.bidi.Dir=} opt_contentDir The content direction; null if * unknown and thus to be estimated when necessary. Default: null. - * @return {!goog.soy.data.SanitizedHtml|soydata.$$EMPTY_STRING_} Wrapped + * @return {!goog.soy.data.SanitizedHtml|!soydata.$$EMPTY_STRING_} Wrapped * result. */ soydata.VERY_UNSAFE.$$ordainSanitizedHtmlForInternalBlocks = @@ -768,8 +825,8 @@ soydata.VERY_UNSAFE.$$ordainSanitizedHtmlForInternalBlocks = /** * Creates kind="js" block contents (internal use only). * - * @param {*} content Text. - * @return {!goog.soy.data.SanitizedJs|soydata.$$EMPTY_STRING_} Wrapped result. + * @param {?} content Text. + * @return {!goog.soy.data.SanitizedJs|!soydata.$$EMPTY_STRING_} Wrapped result. */ soydata.VERY_UNSAFE.$$ordainSanitizedJsForInternalBlocks = soydata.$$makeSanitizedContentFactoryWithDefaultDirOnlyForInternalBlocks_( @@ -779,8 +836,8 @@ soydata.VERY_UNSAFE.$$ordainSanitizedJsForInternalBlocks = /** * Creates kind="trustedResourceUri" block contents (internal use only). * - * @param {*} content Text. - * @return {goog.soy.data.SanitizedTrustedResourceUri|soydata.$$EMPTY_STRING_} + * @param {?} content Text. + * @return {!goog.soy.data.SanitizedTrustedResourceUri|!soydata.$$EMPTY_STRING_} * Wrapped result. */ soydata.VERY_UNSAFE.$$ordainSanitizedTrustedResourceUriForInternalBlocks = @@ -791,8 +848,9 @@ soydata.VERY_UNSAFE.$$ordainSanitizedTrustedResourceUriForInternalBlocks = /** * Creates kind="uri" block contents (internal use only). * - * @param {*} content Text. - * @return {goog.soy.data.SanitizedUri|soydata.$$EMPTY_STRING_} Wrapped result. + * @param {?} content Text. + * @return {!goog.soy.data.SanitizedUri|!soydata.$$EMPTY_STRING_} Wrapped + * result. */ soydata.VERY_UNSAFE.$$ordainSanitizedUriForInternalBlocks = soydata.$$makeSanitizedContentFactoryWithDefaultDirOnlyForInternalBlocks_( @@ -802,8 +860,8 @@ soydata.VERY_UNSAFE.$$ordainSanitizedUriForInternalBlocks = /** * Creates kind="attributes" block contents (internal use only). * - * @param {*} content Text. - * @return {goog.soy.data.SanitizedHtmlAttribute|soydata.$$EMPTY_STRING_} + * @param {?} content Text. + * @return {!goog.soy.data.SanitizedHtmlAttribute|!soydata.$$EMPTY_STRING_} * Wrapped result. */ soydata.VERY_UNSAFE.$$ordainSanitizedAttributesForInternalBlocks = @@ -814,8 +872,9 @@ soydata.VERY_UNSAFE.$$ordainSanitizedAttributesForInternalBlocks = /** * Creates kind="css" block contents (internal use only). * - * @param {*} content Text. - * @return {goog.soy.data.SanitizedCss|soydata.$$EMPTY_STRING_} Wrapped result. + * @param {?} content Text. + * @return {!goog.soy.data.SanitizedCss|!soydata.$$EMPTY_STRING_} Wrapped + * result. */ soydata.VERY_UNSAFE.$$ordainSanitizedCssForInternalBlocks = soydata.$$makeSanitizedContentFactoryWithDefaultDirOnlyForInternalBlocks_( @@ -834,7 +893,7 @@ soydata.VERY_UNSAFE.$$ordainSanitizedCssForInternalBlocks = * double quote '"' in addition to '&', '<', and '>' so that a string can be * included in an HTML tag attribute value within double quotes. * - * @param {*} value The value to convert. If it is already a SanitizedHtml + * @param {?} value The value to convert. If it is already a SanitizedHtml * object, it is left alone. * @return {!goog.soy.data.SanitizedHtml} An escaped version of value. */ @@ -849,34 +908,118 @@ soy.$$escapeHtml = function(value) { * * @param {?} value The string-like value to be escaped. May not be a string, * but the value will be coerced to a string. - * @param {Array=} opt_safeTags Additional tag names to allow-list. + * @param {?Array=} opt_safeTags Additional tag names to whitelist. * @return {!goog.soy.data.SanitizedHtml} A sanitized and normalized version of * value. */ soy.$$cleanHtml = function(value, opt_safeTags) { - if (soydata.isContentKind_(value, goog.soy.data.SanitizedContentKind.HTML)) { - goog.asserts.assert(value.constructor === goog.soy.data.SanitizedHtml); + if (soy.checks.isHtml(value)) { return /** @type {!goog.soy.data.SanitizedHtml} */ (value); } - var tagAllowList; + var tagWhitelist; if (opt_safeTags) { - tagAllowList = goog.object.createSet(opt_safeTags); - goog.object.extend(tagAllowList, soy.esc.$$SAFE_TAG_ALLOW_LIST_); + tagWhitelist = goog.object.createSet(opt_safeTags); + goog.object.extend(tagWhitelist, soy.esc.$$SAFE_TAG_WHITELIST_); } else { - tagAllowList = soy.esc.$$SAFE_TAG_ALLOW_LIST_; + tagWhitelist = soy.esc.$$SAFE_TAG_WHITELIST_; } return soydata.VERY_UNSAFE.ordainSanitizedHtml( - soy.$$stripHtmlTags(value, tagAllowList), soydata.getContentDir(value)); + soy.$$stripHtmlTags(value, tagWhitelist), soydata.getContentDir(value)); }; +// LINT.IfChange(htmlToText) +/** + * Converts HTML to plain text by removing tags, normalizing spaces and + * converting entities. + * + * The last two parameters are idom functions. + * @param {string|?goog.soy.data.SanitizedHtml|?goog.html.SafeHtml| + * ?soydata.IdomFunction|?Function|undefined} value + * @return {string} + */ +soy.$$htmlToText = function(value) { + if (value == null) { + return ''; + } + var html; + if (value instanceof goog.html.SafeHtml) { + html = goog.html.SafeHtml.unwrap(value); + } else if (soydata.isContentKind_( + value, goog.soy.data.SanitizedContentKind.HTML)) { + html = value.toString(); + } else { + return goog.asserts.assertString(value); + } + var text = ''; + var start = 0; + // Tag name to stop removing contents, e.g. '/script'. + var removingUntil = ''; + // Tag name to stop preserving whitespace, e.g. '/pre'. + var wsPreservingUntil = ''; + var tagRe = + /<(?:!--.*?--|(?:!|(\/?[a-z][\w:-]*))(?:[^>'"]|"[^"]*"|'[^']*')*)>|$/gi; + for (var match; match = tagRe.exec(html);) { + var tag = match[1]; + var offset = match.index; + if (!removingUntil) { + var chunk = html.substring(start, offset); + chunk = goog.string.unescapeEntities(chunk); + if (!wsPreservingUntil) { + // We are not inside

, normalize spaces.
+        chunk = chunk.replace(/\s+/g, ' ');
+        if (!/\S$/.test(text)) {
+          // Strip leading space unless after non-whitespace.
+          chunk = chunk.replace(/^ /, '');
+        }
+      }
+      text += chunk;
+      if (/^(script|style|textarea|title)$/i.test(tag)) {
+        removingUntil = '/' + tag.toLowerCase();
+      } else if (/^br$/i.test(tag)) {
+        // 
adds newline even after newline. + text += '\n'; + } else if (soy.BLOCK_TAGS_RE_.test(tag)) { + if (/[^\n]$/.test(text)) { + // Block tags don't add more consecutive newlines. + text += '\n'; + } + if (/^pre$/i.test(tag)) { + wsPreservingUntil = '/' + tag.toLowerCase(); + } else if (tag.toLowerCase() == wsPreservingUntil) { + wsPreservingUntil = ''; + } + } else if (/^(td|th)$/i.test(tag)) { + // We add \t even after newline to support more leading . + text += '\t'; + } + } else if (removingUntil == tag.toLowerCase()) { + removingUntil = ''; + } + if (!match[0]) { + break; + } + start = offset + match[0].length; + } + return text; +}; + + +/** @private @const */ +soy.BLOCK_TAGS_RE_ = + /^\/?(address|blockquote|dd|div|dl|dt|h[1-6]|hr|li|ol|p|pre|table|tr|ul)$/i; +// LINT.ThenChange( +// ../../../third_party/java_src/soy/java/com/google/template/soy/basicfunctions/HtmlToText.java, +// ../../../third_party/java_src/soy/python/runtime/sanitize.py:htmlToText) + + /** * Escapes HTML, except preserves entities. * * Used mainly internally for escaping message strings in attribute and rcdata * context, where we explicitly want to preserve any existing entities. * - * @param {*} value Value to normalize. + * @param {?} value Value to normalize. * @return {string} A value safe to insert in HTML without any quotes or angle * brackets. */ @@ -890,13 +1033,13 @@ soy.$$normalizeHtml = function(value) { * RCDATA. *

* Escapes HTML special characters so that the value will not prematurely end - * the body of a tag like {@code }. + * entity or like a close tag : ``. *

* Will normalize known safe HTML to make sure that sanitized HTML (which could - * contain an innocuous {@code } don't prematurely end an RCDATA + * contain an innocuous `` don't prematurely end an RCDATA * element. * * @param {?} value The string-like value to be escaped. May not be a string, @@ -904,8 +1047,7 @@ soy.$$normalizeHtml = function(value) { * @return {string} An escaped version of value. */ soy.$$escapeHtmlRcdata = function(value) { - if (soydata.isContentKind_(value, goog.soy.data.SanitizedContentKind.HTML)) { - goog.asserts.assert(value.constructor === goog.soy.data.SanitizedHtml); + if (soy.checks.isHtml(value)) { return soy.esc.$$normalizeHtmlHelper(value.getContent()); } return soy.esc.$$escapeHtmlHelper(value); @@ -915,7 +1057,7 @@ soy.$$escapeHtmlRcdata = function(value) { /** * Matches any/only HTML5 void elements' start tags. * See http://www.w3.org/TR/html-markup/syntax.html#syntax-elements - * @type {RegExp} + * @const {!RegExp} * @private */ soy.$$HTML5_VOID_ELEMENTS_ = new RegExp( @@ -925,22 +1067,21 @@ soy.$$HTML5_VOID_ELEMENTS_ = new RegExp( /** * Removes HTML tags from a string of known safe HTML. - * If opt_tagAllowList is not specified or is empty, then + * If opt_tagWhitelist is not specified or is empty, then * the result can be used as an attribute value. * - * @param {*} value The HTML to be escaped. May not be a string, but the + * @param {?} value The HTML to be escaped. May not be a string, but the * value will be coerced to a string. - * @param {Object=} opt_tagAllowList Has an own property whose + * @param {?Object=} opt_tagWhitelist Has an own property whose * name is a lower-case tag name and whose value is `1` for * each element that is allowed in the output. * @return {string} A representation of value without disallowed tags, * HTML comments, or other non-text content. */ -soy.$$stripHtmlTags = function(value, opt_tagAllowList) { - if (!opt_tagAllowList) { - // If we have no allowlist, then use a fast track which elides all tags. - return String(value) - .replace(soy.esc.$$HTML_TAG_REGEX_, '') +soy.$$stripHtmlTags = function(value, opt_tagWhitelist) { + if (!opt_tagWhitelist) { + // If we have no white-list, then use a fast track which elides all tags. + return String(value).replace(soy.esc.$$HTML_TAG_REGEX_, '') // This is just paranoia since callers should normalize the result // anyway, but if they didn't, it would be necessary to ensure that // after the first replace non-tag uses of < do not recombine into @@ -952,47 +1093,49 @@ soy.$$stripHtmlTags = function(value, opt_tagAllowList) { // have been removed. var html = String(value).replace(/\[/g, '['); - // Consider all uses of '<' and replace allow-listed tags with markers like + // Consider all uses of '<' and replace whitelisted tags with markers like // [1] which are indices into a list of approved tag names. // Replace all other uses of < and > with entities. var tags = []; var attrs = []; - html = html.replace(soy.esc.$$HTML_TAG_REGEX_, function(tok, tagName) { - if (tagName) { - tagName = tagName.toLowerCase(); - if (opt_tagAllowList.hasOwnProperty(tagName) && - opt_tagAllowList[tagName]) { - var isClose = tok.charAt(1) == '/'; - var index = tags.length; - var start = ''; + attrs[index] = attributes; + return '[' + index + ']'; } - tags[index] = start + tagName + '>'; - attrs[index] = attributes; - return '[' + index + ']'; } - } - return ''; - }); + return ''; + }); // Escape HTML special characters. Now there are no '<' in html that could // start a tag. @@ -1003,7 +1146,7 @@ soy.$$stripHtmlTags = function(value, opt_tagAllowList) { // Now html contains no tags or less-than characters that could become // part of a tag via a replacement operation and tags only contains // approved tags. - // Reinsert the allowlisted tags. + // Reinsert the white-listed tags. html = html.replace(/\[(\d+)\]/g, function(_, index) { if (attrs[index] && tags[index]) { return tags[index].substr(0, tags[index].length - 1) + attrs[index] + '>'; @@ -1020,7 +1163,7 @@ soy.$$stripHtmlTags = function(value, opt_tagAllowList) { /** * Make sure that tag boundaries are not broken by Safe CSS when embedded in a - * {@code