Page 2 of 3 FirstFirst 1 2 3 LastLast
Results 11 to 20 of 26

Thread: Unusual characters in faxbot monster names cause problems

  1. #11
    Developer Veracity's Avatar
    Join Date
    Mar 2006
    Location
    The Unseelie Court
    Posts
    10,846

    Default

    Code:
    Could not load easyfax configuration from "https://sourceforge.net/p/easyfax/code/HEAD/tree/Easyfax.xml?format=raw"
    I see an error on my console:

    [Fatal Error] easyfax.xml:1557:39: The entity "trade" was referenced, but not declared.

    Line 1157 of the XML file:

    <name>Possessed Jar of Alphredo&trade;</name>

    So, yes - this change to the config file has everything to do with why we cannot load the configuration.

    Apparently the "trade" entity is not built-in to XML and you have to declare it, somehow.
    Ph'nglui mglw'nafh Cthulhu
    R'lyeh wgah-nagl fhtagn.

  2. #12
    Developer Veracity's Avatar
    Join Date
    Mar 2006
    Location
    The Unseelie Court
    Posts
    10,846

    Default

    I tested by changing the start of the easyfax.xml to look like this:

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE faxbot
       [
          <!ENTITY trade  "™">
    ]>
    The DOCTYPE thing is new. We can now successfully parse the file - but it replaces the &trade; with the unicode character and we are back to where we started. That ™ symbol is actually a Unicode character definition: "& #8482 ;" (minus the spaces).

    I then adjusted FaxBotDatabase:

    Code:
    			this.command = CharacterEntities.escape( command );
    And it works like this:

    EasyFax stores the name of the monster with the characters entities.
    EasyFax generates a config file that defines & references the character entity.
    KoLmafia's XML parser reads that config file and gets unicode characters,
    KoLmafia escapes the unicode characters and ends up with the same ASCII string that EasFax has

    --> KoLmafia can send that command via Fax and EasyFax understands it.

    ---

    Alternate solution:

    Easyfax config does NOT have a DOCTYPE. Instead, change the monster:

    Code:
    <monsterdata>
    <name>Possessed Jar of Alphredo&amp;trade;</name>
    <actual_name>Possessed Jar of Alphredo&amp;trade;</actual_name>
    <command>Possessed Jar of Alphredo&amp;trade;</command>
    <category>None</category>
    </monsterdata>
    to not actually have a character entity - just something that XML will expand to look like one.

    KoLmafia's FaxBotDatabase does not entity-encode the command. Same as now.

    Net result is, KoLmafia's "command" agrees with EasyFax's command, and we can get the monster.

    So:

    EasyFax does entity-encode on the monster name it reads from the photocopier.
    It stores that in its command table.
    It does ANOTHER entity encode on the command before it writes it to the XML file. But that's not the one it uses. That's just how it publishes it.
    Ph'nglui mglw'nafh Cthulhu
    R'lyeh wgah-nagl fhtagn.

  3. #13
    Developer fronobulax's Avatar
    Join Date
    Feb 2009
    Location
    D.C. suburbs of Virginia, USA
    Posts
    3,666

    Default

    I'm confused.

    What is the end user solution to
    Could not load easyfax configuration from "https://sourceforge.net/p/easyfax/code/HEAD/tree/Easyfax.xml?format=raw"
    with r17537?

    Short term is edit the file or mafia and the file to implement the changes above, but what is the long term solution? Tell EasyFax how KoLmafia would like to handle trademarks and and then wait for them to update their file?
    You just vehemently agreed with me
    Originally Posted by Veracity View Post
    I agree with frono.
    Originally Posted by Veracity View Post
    There are 69 players more powerful than you.
    Originally Posted by Statistics Leaderboards

  4. #14
    Developer Veracity's Avatar
    Join Date
    Mar 2006
    Location
    The Unseelie Court
    Posts
    10,846

    Default

    Short term solution for the end user is to talk to Easyfax directly with chat, just like non-KoLmafia users do it.

    Relatively short turn solution is for EasyFax to use &amp; in its XML config file for every & character it wants to put there - after it has entity-encoded the monster name, which it currently does.

    I see no need for anything else beyond that. That should be robust even if future monsters have diferent HTML entities.
    Ph'nglui mglw'nafh Cthulhu
    R'lyeh wgah-nagl fhtagn.

  5. #15
    Senior Member Crowther's Avatar
    Join Date
    Nov 2006
    Posts
    1,336

    Default

    Short term solution for the end user is to talk to Easyfax directly with chat, just like non-KoLmafia users do it.

    Relatively short turn solution is for EasyFax to use & in its XML config file for every & character it wants to put there - after it has entity-encoded the monster name, which it currently does.

    I see no need for anything else beyond that. That should be robust even if future monsters have diferent HTML entities.
    Originally Posted by Veracity View Post
    Yup. I can do that. It's a little more messy than it sounds, but not a problem.

  6. #16
    Senior Member Crowther's Avatar
    Join Date
    Nov 2006
    Posts
    1,336

    Default

    Okay. That seems to work. I was able to use the GUI to request that monster. The GUI shows it as "&trade;" so there might be some touching up to do there or not.
    Last edited by Crowther; 12-15-2016 at 03:12 PM.

  7. #17
    Developer Veracity's Avatar
    Join Date
    Mar 2006
    Location
    The Unseelie Court
    Posts
    10,846

    Default

    Yeah, we might want to entity-decode the actual name (but not the command) for display purposes. I'll think about it.
    Thank you for your work!
    Ph'nglui mglw'nafh Cthulhu
    R'lyeh wgah-nagl fhtagn.

  8. #18
    Developer Veracity's Avatar
    Join Date
    Mar 2006
    Location
    The Unseelie Court
    Posts
    10,846

    Default

    Revision 17540 will display pretty monster names, with HTML entities unescaped.
    It will also print the error message if XML parsing throws an error.
    Ph'nglui mglw'nafh Cthulhu
    R'lyeh wgah-nagl fhtagn.

  9. #19
    Senior Member Crowther's Avatar
    Join Date
    Nov 2006
    Posts
    1,336

    Default

    Revision 17540 will display pretty monster names, with HTML entities unescaped.
    It will also print the error message if XML parsing throws an error.
    Originally Posted by Veracity View Post
    Awesome!

    The non-ASCII French teacher seems to work as well.

  10. #20
    Senior Member
    Join Date
    Apr 2009
    Posts
    1,651

    Default

    Alternate solution:

    Easyfax config does NOT have a DOCTYPE. Instead, change the monster:

    Code:
    <monsterdata>
    <name>Possessed Jar of Alphredo&trade;</name>
    <actual_name>Possessed Jar of Alphredo&trade;</actual_name>
    <command>Possessed Jar of Alphredo&trade;</command>
    <category>None</category>
    </monsterdata>
    to not actually have a character entity - just something that XML will expand to look like one.
    Originally Posted by Veracity View Post
    I believe this is the correct way to do it, assuming that mafia will parse string representations of html entities (ie generating the file should use something like xml_encode(entity_encode(...)), depending on language and used libraries). Note that for future compatibility, you should also replace any < with &lt; and > with &gt; ; I don't think you will need to escape " or ' - that's only necessary within element attributes, not inside text nodes.
    The approach with defining xml entities has the problem that you would have to include ALL used html entities in the definition (except the few ones that are also in XML) - either preemtively, by including the whole table in Easyfax.xml, or by scanning all names and somehow determining what to expand them to.

    It's almost the same thing you have with including regexes in java strings, you need an escape layer for each language layer.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •