Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug-Candidate]: Source mapping content corrupted if the contract contains special characters #2612

Open
0xtotem opened this issue Dec 5, 2024 · 1 comment
Labels
bug-candidate Bugs reports that are not yet confirmed

Comments

@0xtotem
Copy link

0xtotem commented Dec 5, 2024

Describe the issue:

If the contract contains special characters, for example french accents, the .source_mapping.content object is returning the expected output, it looks like it's crops by the number of special characters before the source.

Code example to reproduce the issue:

Coin.sol:

// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.4;

contract Coin {
    address public minter;
    mapping (address => uint) public balances;

    event Sent(address from, address to, uint amount);

    // ààà
    constructor() {
        minter = msg.sender;
    }

    // ééé
    function mint(address receiver, uint amount) public {
        require(msg.sender == minter);
        balances[receiver] += amount;
    }
}

If you run:

from slither.slither import Slither  
  
slither = Slither('ok.sol')  

for contract in slither.contracts:
  for f in contract.functions:
    print(f.source_mapping.content)
    print("---")

You get:

structor() {
        minter = msg.sender;
    }

 
---
on mint(address receiver, uint amount) public {
        require(msg.sender == minter);
        balances[receiver] += amount;
    }
}
---

Version:

0.10.4

Relevant log output:

No response

@0xtotem 0xtotem added the bug-candidate Bugs reports that are not yet confirmed label Dec 5, 2024
@smonicas
Copy link
Collaborator

smonicas commented Dec 5, 2024

Hi, we get the source mapping directly from the solc output. It's a known issue in the solidity compiler ethereum/solidity#14733

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug-candidate Bugs reports that are not yet confirmed
Projects
None yet
Development

No branches or pull requests

2 participants