You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The package protected static method named "escape" does the correct job by passing inAttribute at true but I can't call it in the source code above because it's not public. Please can you provide a public method that allows to pass inAttribute at true? It would be cleaner than my dirty kludge that doesn't take into account some other cases.
I suggest the addition of the following method:
/**
* HTML escape an input string within an attribute.
*
* @param string the un-escaped string within an attribute to escape
* @param out the output settings to use
* @return the escaped string
*/
public static String escapeInAttribute(String string, Document.OutputSettings out) {
if (string == null)
return "";
StringBuilder accum = StringUtil.borrowBuilder();
try {
escape(accum, string, out, true, false, false);
} catch (IOException e) {
throw new SerializationException(e); // doesn't happen
}
return StringUtil.releaseBuilder(accum);
}
Best regards and keep up the good work.
The text was updated successfully, but these errors were encountered:
Thanks for the suggestion - I have updated Entities.escape(string) so that it's output is suitable for both text data and attributes. It's more maximal in what gets escaped, so that the string can be used in either context. The output from Element.html() etc is still more conservative, and uses the context of if in an attribute or in text to decide what to escape.
Hello
I need to escape the characters within an attribute in a program that converts an HTML file into a single Java class with a single public static method that converts the Java source code into HTML:
https://github.com/gouessej/HtmlFlow/blob/patch-1/src/main/java/htmlflow/flowifier/AbstractHtmlToJavaHtmlFlowNodeVisitor.java#L319
The package protected static method named "escape" does the correct job by passing inAttribute at true but I can't call it in the source code above because it's not public. Please can you provide a public method that allows to pass inAttribute at true? It would be cleaner than my dirty kludge that doesn't take into account some other cases.
I suggest the addition of the following method:
Best regards and keep up the good work.
The text was updated successfully, but these errors were encountered: