mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-20 11:04:34 +02:00
8146606: Catalog.matchSystem() appends an extra '/' to the matched result
Reviewed-by: lancea
This commit is contained in:
parent
fdb8990307
commit
0224290c87
4 changed files with 72 additions and 15 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -72,6 +72,7 @@ final class RewriteSystem extends BaseEntry {
|
|||
public String getSystemIdStartString () {
|
||||
return systemIdStartString;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the rewritePrefix attribute.
|
||||
* @return The rewritePrefix attribute value.
|
||||
|
@ -80,7 +81,6 @@ final class RewriteSystem extends BaseEntry {
|
|||
return rewritePrefix;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Try to match the specified systemId with the entry. Return the match if it
|
||||
* is successful and the length of the systemIdStartString is longer than the
|
||||
|
@ -91,14 +91,20 @@ final class RewriteSystem extends BaseEntry {
|
|||
* @return The replacement URI if the match is successful, null if not.
|
||||
*/
|
||||
public String match(String systemId, int currentMatch) {
|
||||
if (systemIdStartString.length() <= systemId.length() &&
|
||||
if (systemIdStartString.length() < systemId.length() &&
|
||||
systemIdStartString.equals(systemId.substring(0, systemIdStartString.length()))) {
|
||||
if (currentMatch < systemIdStartString.length()) {
|
||||
String prefix = rewritePrefix.toExternalForm();
|
||||
if (!prefix.endsWith(SLASH) && !systemId.startsWith(SLASH)) {
|
||||
return prefix + SLASH + systemId.substring(systemIdStartString.length());
|
||||
String sysId;
|
||||
if (systemIdStartString.endsWith(SLASH)) {
|
||||
sysId = systemId.substring(systemIdStartString.length());
|
||||
} else {
|
||||
return prefix + systemId.substring(systemIdStartString.length());
|
||||
sysId = systemId.substring(systemIdStartString.length() + 1);
|
||||
}
|
||||
if (prefix.endsWith(SLASH)) {
|
||||
return prefix + sysId;
|
||||
} else {
|
||||
return prefix + SLASH + sysId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -72,6 +72,7 @@ final class RewriteUri extends BaseEntry {
|
|||
public String getURIStartString () {
|
||||
return uriStartString;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the rewritePrefix attribute.
|
||||
* @return The rewritePrefix attribute value.
|
||||
|
@ -91,14 +92,20 @@ final class RewriteUri extends BaseEntry {
|
|||
*/
|
||||
@Override
|
||||
public String match(String systemId, int currentMatch) {
|
||||
if (uriStartString.length() <= systemId.length() &&
|
||||
if (uriStartString.length() < systemId.length() &&
|
||||
uriStartString.equals(systemId.substring(0, uriStartString.length()))) {
|
||||
if (currentMatch < uriStartString.length()) {
|
||||
String prefix = rewritePrefix.toExternalForm();
|
||||
if (!prefix.endsWith(SLASH) && !systemId.startsWith(SLASH)) {
|
||||
return prefix + SLASH + systemId.substring(uriStartString.length());
|
||||
String sysId;
|
||||
if (uriStartString.endsWith(SLASH)) {
|
||||
sysId = systemId.substring(uriStartString.length());
|
||||
} else {
|
||||
return prefix + systemId.substring(uriStartString.length());
|
||||
sysId = systemId.substring(uriStartString.length() + 1);
|
||||
}
|
||||
if (prefix.endsWith(SLASH)) {
|
||||
return prefix + sysId;
|
||||
} else {
|
||||
return prefix + SLASH + sysId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue