project-rubika / issues

6 stars 0 forks source link

Pets can be named slash commands #490

Closed TheTinkeringIdiot closed 3 weeks ago

TheTinkeringIdiot commented 7 months ago

Describe the bug Pets can be named for slash commands.

To Reproduce Steps to reproduce the behavior:

  1. Summon a pet
  2. Target the pet
  3. /pet rename <slash command, example /ymca>
  4. The pet's nameplate reads X (see screenshot)
  5. Pet messages show that the pet's name is a slash command

Expected behavior Slash character should not be allowed in pet names

Screenshots image

Character info: (for the pet)

/ymca [2 None]
------------------------------------
    life    38
    currentnano     63
    fatness     1
    race    1
    monsterdata     96056
    profession  0
    accountflags    0
    expansion   3
    runspeed    23
    losheight   0
    visualprofession    15
    sex     1
    breed   7
    monsterscale    91
    clan    95
    npc_type    100001
    side    0
    cash    0
    health  38
    energy  47
    xp  0
    aggdef  0
    attitude    1
    breedhostility  0
    healinterval    29
    healdelta   3
    strength    9
    agility     9
    stamina     9
    intelligence    9
    sense   9
    psychic     9
    martialarts     12
    brawl   12
    riposte     12
    dimach  12
    onehandbluntweapons     12
    onehandedgedweapon  12
    piercing    12
    twohandedgedweapons     12
    twohandbluntweapons     12
    meleeenergyweapon   12
    parry   15
    sneakattack     12
    meleemultiple   12
    fastattack  12
    throwingknife   12
    grenade     12
    throwngrapplingweapons  12
    bow     12
    pistol  12
    assaultrifle    12
    submachinegun   12
    shotgun     12
    rifle   12
    lr_energyweapon     12
    flingshot   12
    aimedshot   12
    burst   12
    fullauto    12
    bowspecialattack    12
    lr_multipleweapon   12
    closecombatinitiative   15
    distanceweaponinitiative    15
    physicalprowessinitiative   15
    nanoprowessinitiative   15
    swim    15
    bodydevelopment     2
    duck    18
    dodge   18
    evade   18
    projectileac    1
    meleeac     1
    energyac    1
    chemicalac  1
    radiationac     1
    fireac  1
    coldac  1
    nanoac  14
    poisonac    1
    firstaid    15
    treatment   15
    mechanicalengineering   15
    electricalengineering   15
    fieldquantumphysics     15
    weaponsmithing  15
    pharmaceuticals     15
    nanoprogramming     15
    computerliteracy    15
    psychology  15
    chemistry   15
    tutoring    15
    materialmetamorphose    15
    biologicalmetamorphose  15
    psychologicalmodification   15
    materialcreation    15
    materiallocation    15
    senseimprovement    15
    nanoenergypool  15
    flags   403182081
    concealment     15
    breakingentry   15
    disarmtrap  15
    perception  15
    driveground     15
    driveair    15
    mapnavigation   15
    proximityrangeindoors   13
    proximityrangeoutdoors  25
    aggressiveness  0
    conformity  20
    stability   100
    extroverty  30
    headmesh    0
    level   2
    npcfamily   95
    maxncu  10
    equippedweapontype  0
    EquippedRHWeapon    0
    VisualFlags     31
    isfightingme    0
    currentmovementmode     3
    maxnanoenergy   63
    titlelevel  1
    nanointerval    28
    amsmodifier     0
    damageoverridetype  0
    meleedamagemodifier     0
    dmsmodifier     0
    reflectreturnedenergyac     0
    reflectenergyac     0
    absorbenergyac  0
    shieldenergyac  0
    charstate   0
------------------------------------

.getfull succeeded.

Playfield info:

Extended location information:
- 64.5, 180.6, 7.7 (64.5 180.6 y 7.7 954)
- Pf Proxy: Model=51100:954 GS=0 SG=0 R=954, resource: 954
- zone: 33, area: "Junkyard"
Server id: 1, character id: 50000:810, time: 2024-01-17 01:46:37 (UTC)
Version: 00.4.5_EP1, map id: NOT FOUND, build: 52606.

portalerprk commented 7 months ago

@TheTinkeringIdiot - Is there a specific set of allowed characters for Pets? A regex would be nice if you have some thoughts.

TheTinkeringIdiot commented 7 months ago

As I recall (and a quick search to confirm), the colorful pet names we all love are accomplished by starting the name with a 0x10 character, then a single character in the range 0x01-0x7F, followed by the printable name. So something like:

(\x10[\x01-\x7f])?[\w\s]{1,}

Should allow colorful names containing alphanumeric and space characters without allowing the more potentially problematic punctuation. Of course other characters deemed safe can be added easily enough. I can get on live this evening and spend a little time sussing out what the limits are there.

The slash command as a pet name didn't immediately present a problem during my testing, but not knowing how that string gets passed around I thought I'd report it - AO has a long and storied history of failure to validate inputs before using them.

TheTinkeringIdiot commented 7 months ago

The live servers allow the slash in the pet name as well, and similarly the nameplate changes the / to an X. However, the X also appears in the chat, not just the nameplate. So it seems they're just filtering out potentially nasty characters and replacing them, rather than restricting to safe character classes. / becomes X, & becomes '& amp;' (without the space), and @ appears to get dropped, but a single pixel does display that isn't present in names without the @ so I think it's being replaced as well.

image

TheTinkeringIdiot commented 3 weeks ago

Confirmed fixed.

Pet renaming appears to now follow the same conventions as the live game. Closing as complete.