Skip to content

Commit

Permalink
Bugfix: UI 'format' may contains "%", issue-1229 (OpenTSDB#1304)
Browse files Browse the repository at this point in the history
* ui format may contains "%", so encode it in QueryUi.java and decode it in Plot.java
* Add some comment for change.

Signed-off-by: Chris Larsen <[email protected]>
  • Loading branch information
whitelilis authored and manolama committed Dec 11, 2018
1 parent 61ce1fa commit dc31503
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
8 changes: 8 additions & 0 deletions src/graph/Plot.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
Expand Down Expand Up @@ -134,6 +135,13 @@ public Plot(final long start_time, final long end_time, TimeZone tz) {
* </ul>
*/
public void setParams(final Map<String, String> params) {
// check "format y" and "format y2"
String[] y_format_keys = {"format y", "format y2"};
for(String k : y_format_keys){
if(params.containsKey(k)){
params.put(k, URLDecoder.decode(params.get(k)));
}
}
this.params = params;
}

Expand Down
5 changes: 3 additions & 2 deletions src/tsd/client/QueryUi.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
* virtually no exposure to the technology except through the tutorial. --tsuna
*/

import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
Expand Down Expand Up @@ -723,12 +724,12 @@ private void addLabels(final StringBuilder url) {
private void addFormats(final StringBuilder url) {
final String yformat = this.yformat.getText();
if (!yformat.isEmpty()) {
url.append("&yformat=").append(yformat);
url.append("&yformat=").append(URL.encode(yformat));
}
if (y2format.isEnabled()) {
final String y2format = this.y2format.getText();
if (!y2format.isEmpty()) {
url.append("&y2format=").append(y2format);
url.append("&y2format=").append(URL.encode(y2format));
}
}
}
Expand Down

0 comments on commit dc31503

Please sign in to comment.