Skip to content

Commit

Permalink
Handle text creation properly. Fixes #18
Browse files Browse the repository at this point in the history
Creating plaintext would assume valid HTML, which violated POLA. Text will
be escaped when invoking Text.plain(*) and Text.rawHtml(String) will
be the recommended method to send custom HTML in the future
  • Loading branch information
samczsun committed Aug 1, 2015
1 parent ec57014 commit 7f99fd9
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/main/java/com/samczsun/skype4j/formatting/Text.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.samczsun.skype4j.formatting;

import org.apache.commons.lang3.StringEscapeUtils;

/**
* Created by sam on 2015-07-09.
*/
Expand All @@ -14,7 +16,7 @@ public static RichText rich() {
}

public static PlainText plain(String text) {
return new PlainText(text);
return new PlainText(StringEscapeUtils.escapeHtml4(text));
}

public static PlainText plain(byte text) {
Expand Down Expand Up @@ -49,4 +51,7 @@ public static PlainText plain(Object text) {
return plain(text.toString());
}

public static PlainText rawHtml(String html) {
return new PlainText(html);
}
}

0 comments on commit 7f99fd9

Please sign in to comment.